4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-22 00:38:06 +08:00

* sigproc.cc (no_signals_available): Remove exit_state test since signals are

available in a limited fashion when exiting.
(sig_dispatch_pending): Ditto.
(sig_send): Ditto.
(exit_thread): Rearrange to avoid an unnecessary DuplicateProcess when exiting.
(wait_sig): Allow special signals when exiting.
This commit is contained in:
Christopher Faylor 2013-01-03 03:33:18 +00:00
parent 19aef3fa1a
commit d8e0d0a1b9
2 changed files with 24 additions and 16 deletions

View File

@ -1,3 +1,13 @@
2013-01-02 Christopher Faylor <me.cygwin2013@cgf.cx>
* sigproc.cc (no_signals_available): Remove exit_state test since
signals are available in a limited fashion when exiting.
(sig_dispatch_pending): Ditto.
(sig_send): Ditto.
(exit_thread): Rearrange to avoid an unnecessary DuplicateProcess when
exiting.
(wait_sig): Allow special signals when exiting.
2013-01-02 Christopher Faylor <me.cygwin2013@cgf.cx> 2013-01-02 Christopher Faylor <me.cygwin2013@cgf.cx>
* DevNotes: Add entry cgf-000020, relating to previous checkin. * DevNotes: Add entry cgf-000020, relating to previous checkin.

View File

@ -31,7 +31,7 @@ details. */
#define WSSC 60000 // Wait for signal completion #define WSSC 60000 // Wait for signal completion
#define WPSP 40000 // Wait for proc_subproc mutex #define WPSP 40000 // Wait for proc_subproc mutex
#define no_signals_available() (exit_state || (myself->exitcode & EXITCODE_SET) || (&_my_tls == _sig_tls)) #define no_signals_available() ((myself->exitcode & EXITCODE_SET) || (&_my_tls == _sig_tls))
/* /*
* Global variables * Global variables
@ -426,7 +426,7 @@ sigpending (sigset_t *mask)
void __stdcall void __stdcall
sig_dispatch_pending (bool fast) sig_dispatch_pending (bool fast)
{ {
if (exit_state || &_my_tls == _sig_tls) if (&_my_tls == _sig_tls)
{ {
#ifdef DEBUGGING #ifdef DEBUGGING
sigproc_printf ("exit_state %d, cur thread id %p, _sig_tls %p, sigq.start.next %p", sigproc_printf ("exit_state %d, cur thread id %p, _sig_tls %p, sigq.start.next %p",
@ -488,10 +488,14 @@ sigproc_terminate (exit_states es)
void void
exit_thread (DWORD res) exit_thread (DWORD res)
{ {
lock_process for_now; /* May block indefinitely if we're exiting. */
if (exit_state)
{
for_now.release ();
Sleep (INFINITE);
}
HANDLE h; HANDLE h;
# undef ExitThread
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
GetCurrentProcess (), &h, GetCurrentProcess (), &h,
0, FALSE, DUPLICATE_SAME_ACCESS)) 0, FALSE, DUPLICATE_SAME_ACCESS))
@ -502,18 +506,12 @@ exit_thread (DWORD res)
ExitThread (res); ExitThread (res);
} }
ProtectHandle1 (h, exit_thread); ProtectHandle1 (h, exit_thread);
siginfo_t si = {__SIGTHREADEXIT, SI_KERNEL};
si.si_cyg = h;
lock_process for_now; /* May block indefinitely if we're exiting. */
if (exit_state)
{
for_now.release ();
Sleep (INFINITE);
}
/* Tell wait_sig to wait for this thread to exit. It can then release /* Tell wait_sig to wait for this thread to exit. It can then release
the lock below and close the above-opened handle. */ the lock below and close the above-opened handle. */
siginfo_t si = {__SIGTHREADEXIT, SI_KERNEL};
si.si_cyg = h;
sig_send (myself_nowait, si, &_my_tls); sig_send (myself_nowait, si, &_my_tls);
# undef ExitThread
ExitThread (0); ExitThread (0);
} }
@ -579,7 +577,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
set_errno (EAGAIN); set_errno (EAGAIN);
goto out; // Either exiting or not yet initializing goto out; // Either exiting or not yet initializing
} }
wait_for_completion = p != myself_nowait && _my_tls.isinitialized () && !exit_state; wait_for_completion = p != myself_nowait;
p = myself; p = myself;
} }
@ -1336,7 +1334,7 @@ wait_sig (VOID *)
} }
/* Don't process signals when we start exiting */ /* Don't process signals when we start exiting */
if (exit_state && pack.si.si_signo) if (exit_state && pack.si.si_signo > 0)
continue; continue;
sigset_t dummy_mask; sigset_t dummy_mask;