Index: wsock_event.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/wsock_event.h,v retrieving revision 1.2 diff -u -p -r1.2 wsock_event.h --- wsock_event.h 29 Mar 2004 19:41:17 -0000 1.2 +++ wsock_event.h 1 Apr 2004 02:47:36 -0000 @@ -16,6 +16,7 @@ class wsock_event WSAEVENT event; public: wsock_event () : event (NULL) {}; + bool exists () { return event ; } ~wsock_event () { if (event) Index: fhandler_socket.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler_socket.cc,v retrieving revision 1.125 diff -u -p -r1.125 fhandler_socket.cc --- fhandler_socket.cc 31 Mar 2004 15:33:33 -0000 1.125 +++ fhandler_socket.cc 1 Apr 2004 02:47:39 -0000 @@ -964,6 +964,9 @@ fhandler_socket::sendto (const void *ptr else res = ret; + if (res > len) + try_to_debug(0); + /* Special handling for EPIPE and SIGPIPE. EPIPE is generated if the local end has been shut down on a connection @@ -980,6 +983,7 @@ fhandler_socket::sendto (const void *ptr return res; } +int count = 0; int fhandler_socket::sendmsg (const struct msghdr *msg, int flags, ssize_t tot) { @@ -1063,6 +1067,7 @@ fhandler_socket::sendmsg (const struct m } DWORD ret; + wsock_event wsock_evt; if (is_nonblocking () || has_been_closed) res = WSASendTo (get_socket (), wsabuf, iovcnt, (ret = 0, &ret), @@ -1070,7 +1075,6 @@ fhandler_socket::sendmsg (const struct m msg->msg_namelen, NULL, NULL); else { - wsock_event wsock_evt; if (wsock_evt.prepare (get_socket (), FD_CLOSE | FD_WRITE)) { do @@ -1082,6 +1086,7 @@ fhandler_socket::sendmsg (const struct m if (res != SOCKET_ERROR || WSAGetLastError () != WSAEWOULDBLOCK) break; + count++; if (ret > 0) { res = 0; @@ -1089,7 +1094,6 @@ fhandler_socket::sendmsg (const struct m } } while (!(res = wsock_evt.wait (get_socket (), has_been_closed))); - wsock_evt.release (get_socket ()); } } @@ -1097,7 +1101,14 @@ fhandler_socket::sendmsg (const struct m set_winsock_errno (); else res = ret; + + if (wsock_evt.exists ()) + wsock_evt.release (get_socket ()); } + + if (res > tot) + try_to_debug(0); + /* Special handling for EPIPE and SIGPIPE. Index: net.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/net.cc,v retrieving revision 1.165 diff -u -p -r1.165 net.cc --- net.cc 31 Mar 2004 12:04:07 -0000 1.165 +++ net.cc 1 Apr 2004 02:47:42 -0000 @@ -75,35 +75,37 @@ wsock_event::wait (int sock, int &closed { case WSA_WAIT_EVENT_0: WSANETWORKEVENTS evts; - memset (&evts, 0, sizeof evts); - WSAEnumNetworkEvents (sock, event, &evts); - if (evts.lNetworkEvents & FD_READ) + memset (&evts, 0, sizeof evts); /* IS THIS NEEDED? */ + if (!WSAEnumNetworkEvents (sock, event, &evts)) { - if (evts.iErrorCode[FD_READ_BIT]) - wsa_err = evts.iErrorCode[FD_READ_BIT]; - else - ret = 0; + if (evts.lNetworkEvents & FD_READ) + { + if (evts.iErrorCode[FD_READ_BIT]) + wsa_err = evts.iErrorCode[FD_READ_BIT]; + else + ret = 0; + } + else if (evts.lNetworkEvents & FD_WRITE) + { + if (evts.iErrorCode[FD_WRITE_BIT]) + wsa_err = evts.iErrorCode[FD_WRITE_BIT]; + else + ret = 0; + } + if (evts.lNetworkEvents & FD_CLOSE) + { + closed = 1; + if (!wsa_err && evts.iErrorCode[FD_CLOSE_BIT]) + wsa_err = evts.iErrorCode[FD_CLOSE_BIT]; + else + ret = 0; + } + if (wsa_err) + WSASetLastError (wsa_err); } - else if (evts.lNetworkEvents & FD_WRITE) - { - if (evts.iErrorCode[FD_WRITE_BIT]) - wsa_err = evts.iErrorCode[FD_WRITE_BIT]; - else - ret = 0; - } - if (evts.lNetworkEvents & FD_CLOSE) - { - closed = 1; - if (!wsa_err && evts.iErrorCode[FD_CLOSE_BIT]) - wsa_err = evts.iErrorCode[FD_CLOSE_BIT]; - else - ret = 0; - } - if (wsa_err) - WSASetLastError (wsa_err); break; case WSA_WAIT_EVENT_0 + 1: - WSASetLastError (WSAEINTR); + WSASetLastError (WSAEINTR); break; default: WSASetLastError (WSAEFAULT); @@ -116,6 +118,7 @@ wsock_event::release (int sock) { WSAEventSelect (sock, event, 0); WSACloseEvent (event); + event = NULL; unsigned long non_block = 0; ioctlsocket (sock, FIONBIO, &non_block); }