diff options
author | Christopher Faylor <me@cgf.cx> | 2002-09-19 03:30:20 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-09-19 03:30:20 +0000 |
commit | 5bf785a017482da9b87a141e91f91a07a4d433d0 (patch) | |
tree | e0be3c2626e648fa0aabb41d593c4abaef433316 /winsup/cygwin/fhandler_socket.cc | |
parent | 57dfd574a784bd6dbf0bc7c67b28a8283dff6149 (diff) | |
download | cygnal-5bf785a017482da9b87a141e91f91a07a4d433d0.tar.gz cygnal-5bf785a017482da9b87a141e91f91a07a4d433d0.tar.bz2 cygnal-5bf785a017482da9b87a141e91f91a07a4d433d0.zip |
* cygthread.cc (cygthread::initialized): Avoid copying on fork or some threads
may not end up in the pool.
(cygthread::new): Avoid race when checking for initialized. Add debugging
code.
* fhandler.cc (fhandler_base::raw_read): Add case for ERROR_INVALID_HANDLE due
to Win95 directories.
(fhandler_base::open): Handle errors due to Win95 directories.
(fhandler_base::close): Add get_nohandle () test.
(fhandler_base::set_close_on_exec): Ditto.
(fhandler_base::fork_fixup): Ditto.
(fhandler_base::lock): Change error code to Posix EINVAL.
(fhandler_base::dup): If get_nohandle (), set new value to INVALID_HANDLE_VALUE
instead of NULL.
* fhandler_disk_file.cc (fhandler_disk_file::fstat): Call fstat_by_name if
get_nohandle (). Remove extraneous element from strpbrk.
(fhandler_disk_file::open): Remove test for Win95 directory.
* fhandler_random.cc (fhandler_dev_random::open): Add set_nohandle ().
* fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto.
* fhandler_zero.cc (fhandler_dev_zero::open): Ditto.
(fhandler_dev_zero::close): Delete.
* fhandler.h (class fhandler_dev_zero): Ditto.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index f0a819528..5b7e256ac 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -325,7 +325,7 @@ fhandler_socket::bind (const struct sockaddr *name, int namelen) { #define un_addr ((struct sockaddr_un *) name) struct sockaddr_in sin; - int len = sizeof sin; + int len = sizeof sin; int fd; if (strlen (un_addr->sun_path) >= UNIX_PATH_LEN) @@ -513,45 +513,45 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) int wait_result; wait_result = WSAWaitForMultipleEvents (2, ev, FALSE, WSA_INFINITE, - FALSE); - if (wait_result == WSA_WAIT_EVENT_0) - WSAEnumNetworkEvents (get_socket (), ev[0], &sock_event); + FALSE); + if (wait_result == WSA_WAIT_EVENT_0) + WSAEnumNetworkEvents (get_socket (), ev[0], &sock_event); - /* Unset events for listening socket and - switch back to blocking mode */ - WSAEventSelect (get_socket (), ev[0], 0); + /* Unset events for listening socket and + switch back to blocking mode */ + WSAEventSelect (get_socket (), ev[0], 0); unsigned long nonblocking = 0; - ioctlsocket (get_socket (), FIONBIO, &nonblocking); - - switch (wait_result) - { - case WSA_WAIT_EVENT_0: - if (sock_event.lNetworkEvents & FD_ACCEPT) - { - if (sock_event.iErrorCode[FD_ACCEPT_BIT]) - { - WSASetLastError (sock_event.iErrorCode[FD_ACCEPT_BIT]); - set_winsock_errno (); - res = -1; - goto done; - } - } - /* else; : Should never happen since FD_ACCEPT is the only event - that has been selected */ - break; - case WSA_WAIT_EVENT_0 + 1: - debug_printf ("signal received during accept"); - set_errno (EINTR); - res = -1; - goto done; - case WSA_WAIT_FAILED: - default: /* Should never happen */ - WSASetLastError (WSAEFAULT); - set_winsock_errno (); - res = -1; - goto done; - } - } + ioctlsocket (get_socket (), FIONBIO, &nonblocking); + + switch (wait_result) + { + case WSA_WAIT_EVENT_0: + if (sock_event.lNetworkEvents & FD_ACCEPT) + { + if (sock_event.iErrorCode[FD_ACCEPT_BIT]) + { + WSASetLastError (sock_event.iErrorCode[FD_ACCEPT_BIT]); + set_winsock_errno (); + res = -1; + goto done; + } + } + /* else; : Should never happen since FD_ACCEPT is the only event + that has been selected */ + break; + case WSA_WAIT_EVENT_0 + 1: + debug_printf ("signal received during accept"); + set_errno (EINTR); + res = -1; + goto done; + case WSA_WAIT_FAILED: + default: /* Should never happen */ + WSASetLastError (WSAEFAULT); + set_winsock_errno (); + res = -1; + goto done; + } + } } res = ::accept (get_socket (), peer, len); @@ -566,7 +566,7 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) { if (!create_secret_event ()) secret_check_failed = TRUE; - else if (in_progress) + else if (in_progress) signal_secret_event (); } @@ -599,12 +599,12 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) set_winsock_errno (); else { - fhandler_socket* res_fh = fdsock (res_fd, get_name (), res); - if (get_addr_family () == AF_LOCAL) - res_fh->set_sun_path (get_sun_path ()); - res_fh->set_addr_family (get_addr_family ()); - res_fh->set_socket_type (get_socket_type ()); - res = res_fd; + fhandler_socket* res_fh = fdsock (res_fd, get_name (), res); + if (get_addr_family () == AF_LOCAL) + res_fh->set_sun_path (get_sun_path ()); + res_fh->set_addr_family (get_addr_family ()); + res_fh->set_socket_type (get_socket_type ()); + res = res_fd; } } @@ -750,7 +750,7 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags, ssize_t tot) { tot = 0; const struct iovec *iovptr = iov + iovcnt; - do + do { iovptr -= 1; tot += iovptr->iov_len; @@ -903,7 +903,7 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags, { set_errno (EPIPE); if (! (flags & MSG_NOSIGNAL)) - _raise (SIGPIPE); + _raise (SIGPIPE); } return res; @@ -938,7 +938,7 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags, ssize_t tot) { tot = 0; const struct iovec *iovptr = iov + iovcnt; - do + do { iovptr -= 1; tot += iovptr->iov_len; |