diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2006-01-20 13:22:38 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2006-01-20 13:22:38 +0300 |
commit | 1ef48340d51301dd8303e5bca557745c43590bc7 (patch) | |
tree | 065d7e59700d17400abaf3e4d5ce6e3249673118 /winsup/cygwin/fhandler_socket.cc | |
parent | 3c09c0fb256d299373b4d02324fd73eacb850313 (diff) |
* fhandler_socket.cc (fhandler_socket::prepare): Fix debug output.
(fhandler_socket::release): Add debug output for WSAEventSelect failure.
(fhandler_socket::ioctl): Always cancel WSAEventSelect before switching
to blocking mode. Only set nonblocking flag if ioctlsocket call
succeeded. Only print new socket state if ioctlsocket call succeeded.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 80a7c4052..a4ca44faf 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -896,7 +896,7 @@ fhandler_socket::prepare (HANDLE &event, long event_mask) } if (WSAEventSelect (get_socket (), event, event_mask) == SOCKET_ERROR) { - debug_printf ("WSAEventSelect, %E"); + debug_printf ("WSAEventSelect(evt), %d", WSAGetLastError ()); return false; } return true; @@ -994,7 +994,8 @@ fhandler_socket::release (HANDLE event) { int last_err = WSAGetLastError (); /* KB 168349: NT4 fails if the event parameter is not NULL. */ - WSAEventSelect (get_socket (), NULL, 0); + if (WSAEventSelect (get_socket (), NULL, 0) == SOCKET_ERROR) + debug_printf ("WSAEventSelect(NULL), %d", WSAGetLastError ()); WSACloseEvent (event); unsigned long non_block = 0; if (ioctlsocket (get_socket (), FIONBIO, &non_block)) @@ -1495,20 +1496,27 @@ fhandler_socket::ioctl (unsigned int cmd, void *p) /* We must cancel WSAAsyncSelect (if any) before setting socket to * blocking mode */ - if (cmd == FIONBIO && async_io () && *(int *) p == 0) - WSAAsyncSelect (get_socket (), winmsg, 0, 0); + if (cmd == FIONBIO && *(int *) p == 0) + { + if (async_io ()) + WSAAsyncSelect (get_socket (), winmsg, 0, 0); + if (WSAEventSelect (get_socket (), NULL, 0) == SOCKET_ERROR) + debug_printf ("WSAEventSelect(NULL), %d", WSAGetLastError ()); + } res = ioctlsocket (get_socket (), cmd, (unsigned long *) p); if (res == SOCKET_ERROR) set_winsock_errno (); if (cmd == FIONBIO) { - syscall_printf ("socket is now %sblocking", - *(int *) p ? "non" : ""); + if (!res) + { + syscall_printf ("socket is now %sblocking", + *(int *) p ? "non" : ""); + set_nonblocking (*(int *) p); + } /* Start AsyncSelect if async socket unblocked */ if (*(int *) p && async_io ()) WSAAsyncSelect (get_socket (), winmsg, WM_ASYNCIO, ASYNC_MASK); - - set_nonblocking (*(int *) p); } break; } |