Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-03-12 02:30:36 +0300
committerChristopher Faylor <me@cgf.cx>2003-03-12 02:30:36 +0300
commit40b5380edccc8dcac8220061319763fdba98d4f5 (patch)
tree7f84bb2191d2de5ef90a41b804591a365a19218c
parent4e41d421780c3ef4d00679a866e41ae45180805e (diff)
* fhandler_socket.cc (fhandler_socket::dup): Don't call fhandler_base::dup()unlabeled-1.86.2
but call DuplicateHandle directly instead to have control over socket inheritence. * fhandler_socket.cc (fhandler_socket::dup): On NT systems avoid using WinSock2 socket duplication methods. Add comment. * fhandler_socket.cc (fhandler_socket::fixup_after_fork): Set io_handle to INVALID_SOCKET in case of failure. (fhandler_socket::dup): Return 0 if the io_handle is valid. * sec_acl.cc (setacl): Don't handle DELETE flag specially. * security.cc (alloc_sd): Ditto. * winver.rc: Change Copyright hint to include 2003.
-rw-r--r--winsup/cygwin/fhandler_socket.cc32
1 files changed, 27 insertions, 5 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 01965bf67..7617bc23b 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -344,6 +344,7 @@ fhandler_socket::fixup_after_fork (HANDLE parent)
prot_info_ptr, 0, 0)) == INVALID_SOCKET)
{
debug_printf ("WSASocket error");
+ set_io_handle ((HANDLE)INVALID_SOCKET);
set_winsock_errno ();
}
else if (!new_sock && !winsock2_active)
@@ -385,13 +386,34 @@ fhandler_socket::dup (fhandler_base *child)
fhs->set_sun_path (get_sun_path ());
fhs->set_socket_type (get_socket_type ());
- fhs->fixup_before_fork_exec (GetCurrentProcessId ());
- if (winsock2_active)
+ /* Using WinSock2 methods for dup'ing sockets seem to collide
+ with user context switches under... some... conditions. So we
+ drop this for NT systems at all and return to the good ol'
+ DuplicateHandle way of life. This worked fine all the time on
+ NT anyway and it's even a bit faster. */
+ if (!wincap.has_security ())
{
- fhs->fixup_after_fork (hMainProc);
- return 0;
+ fhs->fixup_before_fork_exec (GetCurrentProcessId ());
+ if (winsock2_active)
+ {
+ fhs->fixup_after_fork (hMainProc);
+ return get_io_handle () == (HANDLE) INVALID_SOCKET;
+ }
+ }
+ /* 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;
}
- return fhandler_base::dup (child);
+ child->set_io_handle (nh);
+ return 0;
}
int __stdcall