diff options
author | Christopher Faylor <me@cgf.cx> | 2002-12-14 04:01:32 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-12-14 04:01:32 +0000 |
commit | 8bce0d723c50924b908dca1467037c8008e872be (patch) | |
tree | dcaf982175c090c0e7668af5fa00dac09fb07b27 /winsup/cygwin/cygthread.cc | |
parent | ec085641a9b4d25e16df12d7449f7ad689934117 (diff) | |
download | cygnal-8bce0d723c50924b908dca1467037c8008e872be.tar.gz cygnal-8bce0d723c50924b908dca1467037c8008e872be.tar.bz2 cygnal-8bce0d723c50924b908dca1467037c8008e872be.zip |
Throughout, change fhandler_*::read and fhandler_*::raw_read to void functions
whose second arguments are both the lenght and the return value.
* fhandler.cc (fhandler_base::read): Rework slightly to use second argument as
input/output. Tweak CRLF stuff.
(fhandler_base::readv): Accommodate fhandler_*::read changes.
* cygthread.h (cygthread::detach): Declare as taking optional handle argument.
(cygthread::detach): When given a handle argument, wait for the handle to be
signalled before waiting for thread to detach. Return true when signal
detected.
Diffstat (limited to 'winsup/cygwin/cygthread.cc')
-rw-r--r-- | winsup/cygwin/cygthread.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc index 0c591d01f..48f6c5b15 100644 --- a/winsup/cygwin/cygthread.cc +++ b/winsup/cygwin/cygthread.cc @@ -268,9 +268,10 @@ cygthread::terminate_thread () theory is that cygthreads are only associated with one thread. So, there should be no problems with multiple threads doing waits on the one cygthread. */ -void -cygthread::detach (bool wait_for_sig) +bool +cygthread::detach (HANDLE sigwait) { + bool signalled = false; if (avail) system_printf ("called detach on available thread %d?", avail); else @@ -278,24 +279,32 @@ cygthread::detach (bool wait_for_sig) DWORD avail = id; DWORD res; - if (!wait_for_sig) + if (!sigwait) res = WaitForSingleObject (*this, INFINITE); else { HANDLE w4[2]; w4[0] = signal_arrived; w4[1] = *this; + res = WaitForSingleObject (sigwait, INFINITE); + if (res != WAIT_OBJECT_0) + system_printf ("WFSO sigwait failed, res %u", res); res = WaitForMultipleObjects (2, w4, FALSE, INFINITE); - if (res == WAIT_OBJECT_0) + if (res != WAIT_OBJECT_0) + /* nothing */; + else if (WaitForSingleObject (sigwait, 5) == WAIT_OBJECT_0) + res = WaitForSingleObject (*this, INFINITE); + else { terminate_thread (); set_errno (EINTR); /* caller should be dealing with return values. */ avail = 0; + signalled = true; } } - thread_printf ("%s returns %d, id %p", wait_for_sig ? "WFMO" : "WFSO", + thread_printf ("%s returns %d, id %p", sigwait ? "WFMO" : "WFSO", res, id); if (!avail) @@ -312,6 +321,7 @@ cygthread::detach (bool wait_for_sig) (void) InterlockedExchange ((LPLONG) &this->avail, avail); } } + return signalled; } void |