* exceptions.cc (sigpacket::process): Rework previous change. tls could still

become NULL.
This commit is contained in:
Christopher Faylor 2008-11-28 16:41:54 +00:00
parent fa421c7a75
commit d92ed436e3
2 changed files with 21 additions and 14 deletions

View File

@ -1,3 +1,8 @@
2008-11-28 Christopher Faylor <me+cygwin@cgf.cx>
* exceptions.cc (sigpacket::process): Rework previous change. tls
could still become NULL.
2008-11-28 Christian Franke <franke@computer.org> 2008-11-28 Christian Franke <franke@computer.org>
* dir.cc (readdir_worker): Initialize dirent.d_type and __d_unused1. * dir.cc (readdir_worker): Initialize dirent.d_type and __d_unused1.

View File

@ -1191,9 +1191,7 @@ sigpacket::process ()
else else
handler = NULL; handler = NULL;
bool tls_was_null = !tls; _cygtls *use_tls = tls ?: _main_tls;
if (tls_was_null)
tls = _main_tls;
if (si.si_signo == SIGKILL) if (si.si_signo == SIGKILL)
goto exit_sig; goto exit_sig;
@ -1206,10 +1204,14 @@ sigpacket::process ()
bool insigwait_mask; bool insigwait_mask;
if ((masked = ISSTATE (myself, PID_STOPPED))) if ((masked = ISSTATE (myself, PID_STOPPED)))
insigwait_mask = false; insigwait_mask = false;
else if (tls_was_null) else if (tls)
insigwait_mask = !handler && (tls = _cygtls::find_tls (si.si_signo));
else
insigwait_mask = sigismember (&tls->sigwait_mask, si.si_signo); insigwait_mask = sigismember (&tls->sigwait_mask, si.si_signo);
else
{
insigwait_mask = !handler && (tls = _cygtls::find_tls (si.si_signo));
if (tls)
use_tls = tls;
}
if (insigwait_mask) if (insigwait_mask)
goto thread_specific; goto thread_specific;
@ -1218,7 +1220,7 @@ sigpacket::process ()
/* nothing to do */; /* nothing to do */;
else if (sigismember (mask, si.si_signo)) else if (sigismember (mask, si.si_signo))
masked = true; masked = true;
else else if (tls)
masked = sigismember (&tls->sigmask, si.si_signo); masked = sigismember (&tls->sigmask, si.si_signo);
if (masked) if (masked)
@ -1269,7 +1271,7 @@ sigpacket::process ()
if (handler == (void *) SIG_ERR) if (handler == (void *) SIG_ERR)
goto exit_sig; goto exit_sig;
tls->set_siginfo (this); use_tls->set_siginfo (this);
goto dosig; goto dosig;
stop: stop:
@ -1282,7 +1284,7 @@ stop:
dosig: dosig:
/* Dispatch to the appropriate function. */ /* Dispatch to the appropriate function. */
sigproc_printf ("signal %d, about to call %p", si.si_signo, handler); sigproc_printf ("signal %d, about to call %p", si.si_signo, handler);
rc = setup_handler (si.si_signo, handler, thissig, tls); rc = setup_handler (si.si_signo, handler, thissig, use_tls);
done: done:
if (continue_now) if (continue_now)
@ -1291,10 +1293,10 @@ done:
return rc; return rc;
thread_specific: thread_specific:
tls->sig = si.si_signo; use_tls->sig = si.si_signo;
tls->set_siginfo (this); use_tls->set_siginfo (this);
sigproc_printf ("releasing sigwait for thread"); sigproc_printf ("releasing sigwait for thread");
SetEvent (tls->event); SetEvent (use_tls->event);
goto done; goto done;
exit_sig: exit_sig:
@ -1303,11 +1305,11 @@ exit_sig:
CONTEXT c; CONTEXT c;
c.ContextFlags = CONTEXT_FULL; c.ContextFlags = CONTEXT_FULL;
GetThreadContext (hMainThread, &c); GetThreadContext (hMainThread, &c);
tls->copy_context (&c); use_tls->copy_context (&c);
si.si_signo |= 0x80; si.si_signo |= 0x80;
} }
sigproc_printf ("signal %d, about to call do_exit", si.si_signo); sigproc_printf ("signal %d, about to call do_exit", si.si_signo);
tls->signal_exit (si.si_signo); /* never returns */ use_tls->signal_exit (si.si_signo); /* never returns */
} }
/* Cover function to `do_exit' to handle exiting even in presence of more /* Cover function to `do_exit' to handle exiting even in presence of more