diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2017-11-27 13:38:21 +0100 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2017-11-27 13:38:21 +0100 |
commit | 9789cdffde8bd365ca8fa94e924c870fa043e28a (patch) | |
tree | 11153c278580529100c140b83e3cf0bcd64c126f | |
parent | 569d048c892bcfd99707a351b8a345b2b977a0b6 (diff) | |
download | newlib-9789cdffde8bd365ca8fa94e924c870fa043e28a.zip newlib-9789cdffde8bd365ca8fa94e924c870fa043e28a.tar.gz newlib-9789cdffde8bd365ca8fa94e924c870fa043e28a.tar.bz2 |
cygwin: cleanup fhandler_socket::release_events
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index b8e684f..cc75b97 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -801,14 +801,16 @@ fhandler_socket::wait_for_events (const long event_mask, const DWORD flags) void fhandler_socket::release_events () { - HANDLE evt = wsock_evt; - HANDLE mtx = wsock_mtx; + if (WaitForSingleObject (wsock_mtx, INFINITE) != WAIT_FAILED) + { + HANDLE evt = wsock_evt; + HANDLE mtx = wsock_mtx; - LOCK_EVENTS; - wsock_evt = wsock_mtx = NULL; - } ReleaseMutex (mtx); /* == UNLOCK_EVENTS, but note using local mtx here. */ - NtClose (evt); - NtClose (mtx); + wsock_evt = wsock_mtx = NULL; + ReleaseMutex (mtx); + NtClose (evt); + NtClose (mtx); + } } /* Called from net.cc:fdsock() if a freshly created socket is not |