diff options
author | Christopher Faylor <me@cgf.cx> | 2005-09-23 15:18:22 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2005-09-23 15:18:22 +0000 |
commit | 255e7e559ee76ca82cf30aa47486ec8736d88521 (patch) | |
tree | 46732877a33de63baffe29d4ce94b94b61105989 /winsup | |
parent | e7a76793ad2d882d68a81f217cecffa1c64e892c (diff) | |
download | newlib-255e7e559ee76ca82cf30aa47486ec8736d88521.zip newlib-255e7e559ee76ca82cf30aa47486ec8736d88521.tar.gz newlib-255e7e559ee76ca82cf30aa47486ec8736d88521.tar.bz2 |
* cygtls.h (struct _cygtls::thread_handle): Remove/revert.
* sigproc.h (struct sipacket::thread_handle): Put thread_handle here.
* sigproc.cc (sigproc_terminate): Move setting of thread_handle...
(sig_send): ...to here. Put it in packet being sent. Only close pack.wakeup
when we're waiting for completion.
(wait_sig): Use thread_handle directly from received packet.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 9 | ||||
-rw-r--r-- | winsup/cygwin/cygtls.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 29 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.h | 1 |
4 files changed, 23 insertions, 17 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 17c250e..a5d5fb2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2005-09-23 Christopher Faylor <cgf@timesys.com> + + * cygtls.h (struct _cygtls::thread_handle): Remove/revert. + * sigproc.h (struct sipacket::thread_handle): Put thread_handle here. + * sigproc.cc (sigproc_terminate): Move setting of thread_handle... + (sig_send): ...to here. Put it in packet being sent. Only close + pack.wakeup when we're waiting for completion. + (wait_sig): Use thread_handle directly from received packet. + 2005-09-22 Christopher Faylor <cgf@timesys.com> * cygheap.cc (cygheap_fixup_in_child): It's not just for exec. diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index 9bffe8f..008de05 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -184,7 +184,6 @@ struct _cygtls class cygthread *_ctinfo; san andreas; waitq wq; - HANDLE thread_handle; struct _cygtls *prev, *next; __stack_t *stackptr; int sig; diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 8d84551..6bcb6bc 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -500,11 +500,6 @@ sigproc_terminate (exit_states es) siginfo_t si; memset (&si, 0, sizeof (si)); si.si_signo = __SIGEXIT; - if (&_my_tls == _main_tls) - _my_tls.thread_handle = hMainThread; - else - DuplicateHandle (hMainProc, GetCurrentThread (), hMainProc, &_my_tls.thread_handle, 0, - FALSE, DUPLICATE_SAME_ACCESS); sig_send (myself_nowait, si, &_my_tls); proc_terminate (); // clean up process stuff } @@ -626,7 +621,15 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) pack.si.si_uid = myself->uid; pack.pid = myself->pid; pack.tls = (_cygtls *) tls; - if (wait_for_completion) + if (si.si_signo == __SIGEXIT) + { + if (&_my_tls == _main_tls) + pack.thread_handle = hMainThread; + else + DuplicateHandle (hMainProc, GetCurrentThread (), hMainProc, &pack.thread_handle, 0, + FALSE, DUPLICATE_SAME_ACCESS); + } + else if (wait_for_completion) { pack.wakeup = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL); sigproc_printf ("wakeup %p", pack.wakeup); @@ -667,6 +670,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) { sigproc_printf ("Waiting for pack.wakeup %p", pack.wakeup); rc = WaitForSingleObject (pack.wakeup, WSSC); + ForceCloseHandle (pack.wakeup); } else { @@ -677,12 +681,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) ForceCloseHandle (sendsig); } - if (pack.wakeup) - { - ForceCloseHandle (pack.wakeup); - pack.wakeup = NULL; - } - + pack.wakeup = NULL; if (rc == WAIT_OBJECT_0) rc = 0; // Successful exit else @@ -1124,11 +1123,9 @@ wait_sig (VOID *self) } my_sendsig = NULL; - if (!pack.tls) - api_fatal ("no exit packet received"); - if (!pack.tls->thread_handle) + HANDLE& h = pack.thread_handle; + if (!h) api_fatal ("no thread handle set on exit"); - HANDLE h = pack.tls->thread_handle; DWORD res = WaitForSingleObject (h, INFINITE); DWORD exitcode = 1; diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index a53da0c..e1230a1 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -47,6 +47,7 @@ struct sigpacket union { HANDLE wakeup; + HANDLE thread_handle; struct sigpacket *next; }; int __stdcall process () __attribute__ ((regparm (1))); |