diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2003-06-03 01:14:39 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2003-06-03 01:14:39 +0400 |
commit | dfe7d288506ffd94cd2acb295881d22da502d191 (patch) | |
tree | 2257de51dfda15f2336ab2d57c21cb469cddee07 /winsup/cygwin/fhandler_socket.cc | |
parent | 8e13bd144dbee1439bea0d124850c9da73c1c6f6 (diff) |
* fhandler_socket.cc (fhandler_socket::connect): Simplify previous
patch.
(fhandler_socket::accept): Ditto.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r-- | winsup/cygwin/fhandler_socket.cc | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index b2a8ce1cd..53e4e3bb8 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -534,21 +534,11 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen) { sock_thread_data cd = { get_socket (), (sockaddr *) &sin, &namelen, -1 }; cygthread *thread = new cygthread (connect_thread, &cd, "connect"); - HANDLE wait_events[2] = { *thread, signal_arrived }; - if (WaitForMultipleObjects(2, wait_events, FALSE, INFINITE) - != WAIT_OBJECT_0) - { - /* Signal arrived */ - thread->terminate_thread (); - interrupted = TRUE; - } - else - { - /* connect returned normally */ - res = cd.ret; - thread->detach (); - } - delete thread; + HANDLE waitevt = CreateEvent(&sec_none_nih, FALSE, TRUE, NULL); + interrupted = thread->detach (waitevt); + CloseHandle (waitevt); + if (!interrupted) + res = cd.ret; } else res = ::connect (get_socket (), (sockaddr *) &sin, namelen); @@ -652,20 +642,12 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) { sock_thread_data ad = { get_socket (), peer, len, -1 }; cygthread *thread = new cygthread (accept_thread, &ad, "accept"); - HANDLE wait_events[2] = { *thread, signal_arrived }; - if (WaitForMultipleObjects(2, wait_events, FALSE, INFINITE) - != WAIT_OBJECT_0) - { - /* Signal arrived */ - thread->terminate_thread (); - delete thread; - set_errno (EINTR); - return -1; - } - /* accept returned normally */ + HANDLE waitevt = CreateEvent(&sec_none_nih, FALSE, TRUE, NULL); + bool signalled = thread->detach (waitevt); + CloseHandle (waitevt); + if (signalled) + return -1; res = ad.ret; - thread->detach (); - delete thread; } else res = ::accept (get_socket (), peer, len); |