diff options
author | Christopher Faylor <me@cgf.cx> | 2011-12-04 17:58:24 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2011-12-04 17:58:24 +0000 |
commit | 8f937028d9b8d387cf35b64d92056241bffabd78 (patch) | |
tree | 2ed73616733809fc902b1e33bc2370a0468ba142 /winsup/cygwin/exceptions.cc | |
parent | 69864e48cb0ef1efd1ac29a80b34bbc9c604533b (diff) | |
download | cygnal-8f937028d9b8d387cf35b64d92056241bffabd78.tar.gz cygnal-8f937028d9b8d387cf35b64d92056241bffabd78.tar.bz2 cygnal-8f937028d9b8d387cf35b64d92056241bffabd78.zip |
* exceptions.cc (exception::handle): Drop abbreviation for "exception" since I
never remember what it stands for.
(sig_handle_tty_stop): Remove obsolete call to sig_handle_tty_stop.
(_cygtls::call_signal_handler): Rework to grab signal information from
_main_tls if none is set for _my_tls. Try harder to keep thread locked.
(reset_signal_arrived): Delete.
* fhandler.cc (fhandler_base_overlapped::wait_overlapped): Use new cygWFMO call
to wait for an event + standard cygwin stuff. Modify debug output to
acccomodate new function.
* fhandler_console.cc (fhandler_console::read): Replace WaitForMultipleObjects
with cygWFMO.
* fhandler_socket.cc (get_inet_addr): Add comment.
* gendef (_sigdelayed): Remove call to reset_signal_arrived.
* sigproc.cc (_cygtls::signal_exit): Don't close my_readsig here unless we're
in the signal thread.
(create_signal_arrived): Create signal_arrived as auto-reset so that only one
thread is woken when a signal arrives.
* sigproc.h (cygWFMO): New function.
(reset_signal_arrived): Delete declaration.
Diffstat (limited to 'winsup/cygwin/exceptions.cc')
-rw-r--r-- | winsup/cygwin/exceptions.cc | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 5e6137ffd..c62b81662 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -600,7 +600,7 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, void return 1; } - debug_printf ("In cygwin_except_handler exc %p at %p sp %p", e->ExceptionCode, in->Eip, in->Esp); + debug_printf ("In cygwin_except_handler exception %p at %p sp %p", e->ExceptionCode, in->Eip, in->Esp); debug_printf ("In cygwin_except_handler signal %d at %p", si.si_signo, in->Eip); bool masked = !!(me.sigmask & SIGTOMASK (si.si_signo)); @@ -755,7 +755,6 @@ sig_handle_tty_stop (int sig) { case WAIT_OBJECT_0: case WAIT_OBJECT_0 + 1: - reset_signal_arrived (); myself->stopsig = SIGCONT; myself->alert_parent (SIGCONT); break; @@ -1325,25 +1324,42 @@ events_terminate () int _cygtls::call_signal_handler () { - int this_sa_flags = 0; - /* Call signal handler. */ - while (sig && func) + int this_sa_flags = SA_RESTART; + while (1) { lock (); + if (sig) + pop (); + else if (this != _main_tls) + { + _main_tls->lock (); + if (_main_tls->sig) + { + sig = _main_tls->sig; + sa_flags = _main_tls->sa_flags; + func = _main_tls->func; + infodata = _main_tls->infodata; + _main_tls->pop (); + _main_tls->sig = 0; + + } + _main_tls->unlock (); + } + if (!sig) + break; + this_sa_flags = sa_flags; int thissig = sig; void (*thisfunc) (int) = func; - pop (); - reset_signal_arrived (); sigset_t this_oldmask = set_process_mask_delta (); int this_errno = saved_errno; sig = 0; unlock (); // make sure synchronized - incyg = 0; if (!(this_sa_flags & SA_SIGINFO)) { void (*sigfunc) (int) = thisfunc; + incyg = false; sigfunc (thissig); } else @@ -1351,27 +1367,19 @@ _cygtls::call_signal_handler () siginfo_t thissi = infodata; void (*sigact) (int, siginfo_t *, void *) = (void (*) (int, siginfo_t *, void *)) thisfunc; /* no ucontext_t information provided yet */ + incyg = false; sigact (thissig, &thissi, NULL); } - incyg = 1; + incyg = true; set_signal_mask (this_oldmask, _my_tls.sigmask); if (this_errno >= 0) set_errno (this_errno); } + unlock (); return this_sa_flags & SA_RESTART; } -extern "C" void __stdcall -reset_signal_arrived () -{ - // NEEDED? WaitForSingleObject (signal_arrived, 10); - ResetEvent (signal_arrived); - sigproc_printf ("reset signal_arrived"); - if (_my_tls.stackptr > _my_tls.stack) - debug_printf ("stackptr[-1] %p", _my_tls.stackptr[-1]); -} - void _cygtls::copy_context (CONTEXT *c) { |