aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/net.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2004-04-01 09:48:15 +0000
committerCorinna Vinschen <corinna@vinschen.de>2004-04-01 09:48:15 +0000
commit54aefcc6bc3422afd8b59b000202e17bf3baab2d (patch)
tree254fb88542f1ad45a9a92c66c95f6adc3020dbc5 /winsup/cygwin/net.cc
parentfbba4780afa4e15effff7ae122252cbf919ac77e (diff)
downloadnewlib-54aefcc6bc3422afd8b59b000202e17bf3baab2d.zip
newlib-54aefcc6bc3422afd8b59b000202e17bf3baab2d.tar.gz
newlib-54aefcc6bc3422afd8b59b000202e17bf3baab2d.tar.bz2
* fhandler_socket.cc (fhandler_socket::sendto): Drop out of loop if
has_been_closed gets set. (fhandler_socket::sendmsg): Ditto. * net.cc (wsock_event::wait): Don't initialize evts. Don't try to evaluate network events if WSAEnumNetworkEvents fails. (wsock_event::release): Save last WSA error and set it again unless resetting to blocking socket fails. * wsock_event.h (class wsock_event): Remove destructor.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc55
1 files changed, 30 insertions, 25 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 0bdff32..2459580 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -75,32 +75,33 @@ 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)
+ if (!WSAEnumNetworkEvents (sock, event, &evts))
{
- 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 (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);
}
- if (wsa_err)
- WSASetLastError (wsa_err);
break;
case WSA_WAIT_EVENT_0 + 1:
WSASetLastError (WSAEINTR);
@@ -114,10 +115,14 @@ wsock_event::wait (int sock, int &closed)
void
wsock_event::release (int sock)
{
+ int last_err = WSAGetLastError ();
WSAEventSelect (sock, event, 0);
WSACloseEvent (event);
unsigned long non_block = 0;
- ioctlsocket (sock, FIONBIO, &non_block);
+ if (ioctlsocket (sock, FIONBIO, &non_block))
+ debug_printf ("return to blocking failed: %d", WSAGetLastError ());
+ else
+ WSASetLastError (last_err);
}
WSADATA wsadata;