* cygtls.cc (_threadinfo::remove): Don't assume that we are removing _my_tls.
* exceptions.cc (setup_handler): Improve debugging output. (call_signal_handler_now): Remove ill-advised debugger call. * sigproc.cc (sigcomplete_main): Delete. (sig_send): Honor FIXME and avoid using main thread's completion event for everything or suffer races. (pending_signals::add): Default stored mask to current process mask rather than mask at time of signal send. (wait_sig): Add debugging output. * sigproc.h (sigpacket::mask_storage): Delete.
This commit is contained in:
parent
537ca63f8e
commit
39d06d71ff
|
@ -1,3 +1,17 @@
|
||||||
|
2004-01-22 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
* cygtls.cc (_threadinfo::remove): Don't assume that we are removing
|
||||||
|
_my_tls.
|
||||||
|
* exceptions.cc (setup_handler): Improve debugging output.
|
||||||
|
(call_signal_handler_now): Remove ill-advised debugger call.
|
||||||
|
* sigproc.cc (sigcomplete_main): Delete.
|
||||||
|
(sig_send): Honor FIXME and avoid using main thread's completion event
|
||||||
|
for everything or suffer races.
|
||||||
|
(pending_signals::add): Default stored mask to current process mask
|
||||||
|
rather than mask at time of signal send.
|
||||||
|
(wait_sig): Add debugging output.
|
||||||
|
* sigproc.h (sigpacket::mask_storage): Delete.
|
||||||
|
|
||||||
2004-01-22 Christopher Faylor <cgf@redhat.com>
|
2004-01-22 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* fhandler.cc (fhandler_base::open): Revert isfs change.
|
* fhandler.cc (fhandler_base::open): Revert isfs change.
|
||||||
|
|
|
@ -140,10 +140,11 @@ _threadinfo::remove (DWORD wait)
|
||||||
if (here.acquired ())
|
if (here.acquired ())
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < nthreads; i++)
|
for (size_t i = 0; i < nthreads; i++)
|
||||||
if (&_my_tls == cygheap->threadlist[i])
|
if (this == cygheap->threadlist[i])
|
||||||
{
|
{
|
||||||
if (i < --nthreads)
|
if (i < --nthreads)
|
||||||
cygheap->threadlist[i] = cygheap->threadlist[nthreads];
|
cygheap->threadlist[i] = cygheap->threadlist[nthreads];
|
||||||
|
debug_printf ("removed %p element %d", this, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -744,7 +744,11 @@ setup_handler (int sig, void *handler, struct sigaction& siga, _threadinfo *tls)
|
||||||
bool interrupted = false;
|
bool interrupted = false;
|
||||||
|
|
||||||
if (tls->sig)
|
if (tls->sig)
|
||||||
|
{
|
||||||
|
sigproc_printf ("trying to send sig %d but signal %d already armed",
|
||||||
|
sig, tls->sig);
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < CALL_HANDLER_RETRY; i++)
|
for (int i = 0; i < CALL_HANDLER_RETRY; i++)
|
||||||
{
|
{
|
||||||
|
@ -1141,10 +1145,6 @@ call_signal_handler_now ()
|
||||||
void (*sigfunc) (int) = _my_tls.func;
|
void (*sigfunc) (int) = _my_tls.func;
|
||||||
|
|
||||||
(void) _my_tls.pop ();
|
(void) _my_tls.pop ();
|
||||||
#ifdef DEBUGGING
|
|
||||||
if (_my_tls.stackptr > (_my_tls.stack + 1))
|
|
||||||
try_to_debug ();
|
|
||||||
#endif
|
|
||||||
reset_signal_arrived ();
|
reset_signal_arrived ();
|
||||||
sigset_t oldmask = _my_tls.oldmask;
|
sigset_t oldmask = _my_tls.oldmask;
|
||||||
int this_errno = _my_tls.saved_errno;
|
int this_errno = _my_tls.saved_errno;
|
||||||
|
|
|
@ -114,9 +114,6 @@ HANDLE NO_COPY signal_arrived; // Event signaled when a signal has
|
||||||
|
|
||||||
Static DWORD proc_loop_wait = 1000; // Wait for subprocesses to exit
|
Static DWORD proc_loop_wait = 1000; // Wait for subprocesses to exit
|
||||||
|
|
||||||
Static HANDLE sigcomplete_main; // Event signaled when a signal has
|
|
||||||
// finished processing for the main
|
|
||||||
// thread
|
|
||||||
HANDLE NO_COPY sigCONT; // Used to "STOP" a process
|
HANDLE NO_COPY sigCONT; // Used to "STOP" a process
|
||||||
Static cygthread *hwait_sig; // Handle of wait_sig thread
|
Static cygthread *hwait_sig; // Handle of wait_sig thread
|
||||||
Static cygthread *hwait_subproc; // Handle of sig_subproc thread
|
Static cygthread *hwait_subproc; // Handle of sig_subproc thread
|
||||||
|
@ -646,7 +643,6 @@ sigproc_terminate (void)
|
||||||
{
|
{
|
||||||
sigproc_printf ("entering");
|
sigproc_printf ("entering");
|
||||||
// finished with anything it is doing
|
// finished with anything it is doing
|
||||||
ForceCloseHandle (sigcomplete_main);
|
|
||||||
if (!hExeced)
|
if (!hExeced)
|
||||||
{
|
{
|
||||||
HANDLE sendsig = myself->sendsig;
|
HANDLE sendsig = myself->sendsig;
|
||||||
|
@ -681,8 +677,8 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
|
||||||
HANDLE sendsig;
|
HANDLE sendsig;
|
||||||
sigpacket pack;
|
sigpacket pack;
|
||||||
|
|
||||||
|
pack.wakeup = NULL;
|
||||||
bool wait_for_completion;
|
bool wait_for_completion;
|
||||||
// FIXMENOW: Avoid using main thread's completion event!
|
|
||||||
if (!(its_me = (p == NULL || p == myself || p == myself_nowait)))
|
if (!(its_me = (p == NULL || p == myself || p == myself_nowait)))
|
||||||
wait_for_completion = false;
|
wait_for_completion = false;
|
||||||
else
|
else
|
||||||
|
@ -710,11 +706,7 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (its_me)
|
if (its_me)
|
||||||
{
|
|
||||||
sendsig = myself->sendsig;
|
sendsig = myself->sendsig;
|
||||||
if (wait_for_completion)
|
|
||||||
pack.wakeup = sigcomplete_main;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HANDLE hp = OpenProcess (PROCESS_DUP_HANDLE, false, p->dwProcessId);
|
HANDLE hp = OpenProcess (PROCESS_DUP_HANDLE, false, p->dwProcessId);
|
||||||
|
@ -756,7 +748,13 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
|
||||||
pack.si.si_uid = myself->uid;
|
pack.si.si_uid = myself->uid;
|
||||||
pack.pid = myself->pid;
|
pack.pid = myself->pid;
|
||||||
pack.tls = (_threadinfo *) tls;
|
pack.tls = (_threadinfo *) tls;
|
||||||
pack.mask_storage = 0;
|
if (wait_for_completion)
|
||||||
|
{
|
||||||
|
pack.wakeup = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
||||||
|
sigproc_printf ("wakeup %p", pack.wakeup);
|
||||||
|
ProtectHandle (pack.wakeup);
|
||||||
|
}
|
||||||
|
|
||||||
DWORD nb;
|
DWORD nb;
|
||||||
if (!WriteFile (sendsig, &pack, sizeof (pack), &nb, NULL) || nb != sizeof (pack))
|
if (!WriteFile (sendsig, &pack, sizeof (pack), &nb, NULL) || nb != sizeof (pack))
|
||||||
{
|
{
|
||||||
|
@ -815,6 +813,9 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
|
||||||
call_signal_handler_now ();
|
call_signal_handler_now ();
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
if (pack.wakeup)
|
||||||
|
ForceCloseHandle (pack.wakeup);
|
||||||
|
|
||||||
if (si.si_signo != __SIGPENDING)
|
if (si.si_signo != __SIGPENDING)
|
||||||
/* nothing */;
|
/* nothing */;
|
||||||
else if (!rc)
|
else if (!rc)
|
||||||
|
@ -1028,8 +1029,7 @@ pending_signals::add (sigpacket& pack)
|
||||||
empty = 0;
|
empty = 0;
|
||||||
se = sigs + empty;
|
se = sigs + empty;
|
||||||
*se = pack;
|
*se = pack;
|
||||||
se->mask_storage = *(pack.mask);
|
se->mask = &myself->getsigmask ();
|
||||||
se->mask = &se->mask_storage;
|
|
||||||
se->next = NULL;
|
se->next = NULL;
|
||||||
if (end)
|
if (end)
|
||||||
end->next = se;
|
end->next = se;
|
||||||
|
@ -1077,12 +1077,8 @@ wait_sig (VOID *self)
|
||||||
/* Initialization */
|
/* Initialization */
|
||||||
(void) SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY);
|
(void) SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY);
|
||||||
|
|
||||||
/* sigcomplete_main - event used to signal main thread on signal
|
|
||||||
completion */
|
|
||||||
if (!CreatePipe (&readsig, &myself->sendsig, sec_user_nih (sa_buf), 0))
|
if (!CreatePipe (&readsig, &myself->sendsig, sec_user_nih (sa_buf), 0))
|
||||||
api_fatal ("couldn't create signal pipe, %E");
|
api_fatal ("couldn't create signal pipe, %E");
|
||||||
sigcomplete_main = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
|
||||||
sigproc_printf ("sigcomplete_main %p", sigcomplete_main);
|
|
||||||
sigCONT = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
sigCONT = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
|
||||||
|
|
||||||
/* Setting dwProcessId flags that this process is now capable of receiving
|
/* Setting dwProcessId flags that this process is now capable of receiving
|
||||||
|
@ -1093,8 +1089,6 @@ wait_sig (VOID *self)
|
||||||
myself->process_state |= PID_ACTIVE;
|
myself->process_state |= PID_ACTIVE;
|
||||||
myself->process_state &= ~PID_INITIALIZING;
|
myself->process_state &= ~PID_INITIALIZING;
|
||||||
|
|
||||||
ProtectHandle (sigcomplete_main);
|
|
||||||
|
|
||||||
/* If we've been execed, then there is still a stub left in the previous
|
/* If we've been execed, then there is still a stub left in the previous
|
||||||
windows process waiting to see if it's started a cygwin process or not.
|
windows process waiting to see if it's started a cygwin process or not.
|
||||||
Signalling subproc_ready indicates that we are a cygwin process. */
|
Signalling subproc_ready indicates that we are a cygwin process. */
|
||||||
|
@ -1193,7 +1187,10 @@ wait_sig (VOID *self)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pack.wakeup)
|
if (pack.wakeup)
|
||||||
|
{
|
||||||
SetEvent (pack.wakeup);
|
SetEvent (pack.wakeup);
|
||||||
|
sigproc_printf ("signalled %p", pack.wakeup);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sigproc_printf ("done");
|
sigproc_printf ("done");
|
||||||
|
|
|
@ -55,7 +55,6 @@ struct sigpacket
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
class _threadinfo *tls;
|
class _threadinfo *tls;
|
||||||
sigset_t *mask;
|
sigset_t *mask;
|
||||||
sigset_t mask_storage;
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
HANDLE wakeup;
|
HANDLE wakeup;
|
||||||
|
|
Loading…
Reference in New Issue