This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] cygwin: cleanup fhandler_socket::release_events


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9789cdffde8bd365ca8fa94e924c870fa043e28a

commit 9789cdffde8bd365ca8fa94e924c870fa043e28a
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Mon Nov 27 13:38:21 2017 +0100

    cygwin: cleanup fhandler_socket::release_events
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler_socket.cc | 16 +++++++++-------
 1 file 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]