OSDN Git Service

* fhandler_socket.cc (fhandler_socket::dup): Don't call
authorcorinna <corinna>
Tue, 11 Mar 2003 16:49:58 +0000 (16:49 +0000)
committercorinna <corinna>
Tue, 11 Mar 2003 16:49:58 +0000 (16:49 +0000)
fhandler_base::dup() but call DuplicateHandle directly instead to have
control over socket inheritence.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_socket.cc

index 6751d18..fe3b933 100644 (file)
@@ -1,5 +1,11 @@
 2003-03-11  Corinna Vinschen  <corinna@vinschen.de>
 
+       * fhandler_socket.cc (fhandler_socket::dup): Don't call
+       fhandler_base::dup() but call DuplicateHandle directly instead to have
+       control over socket inheritence.
+
+2003-03-11  Corinna Vinschen  <corinna@vinschen.de>
+
        * fhandler_socket.cc (fhandler_socket::dup): On NT systems avoid
        using WinSock2 socket duplication methods.  Add comment.
 
index c673df2..7617bc2 100644 (file)
@@ -400,7 +400,20 @@ fhandler_socket::dup (fhandler_base *child)
          return get_io_handle () == (HANDLE) INVALID_SOCKET;
        }
     }
-  return fhandler_base::dup (child);
+  /* We don't call fhandler_base::dup here since that requires to
+     have winsock called from fhandler_base and it creates only
+     inheritable sockets which is wrong for winsock2. */
+  HANDLE nh;
+  if (!DuplicateHandle (hMainProc, get_io_handle (), hMainProc, &nh, 0,
+                       !winsock2_active, DUPLICATE_SAME_ACCESS))
+    {
+      system_printf ("dup(%s) failed, handle %x, %E",
+                    get_name (), get_io_handle ());
+      __seterrno ();
+      return -1;
+    }
+  child->set_io_handle (nh);
+  return 0;
 }
 
 int __stdcall