* cygtls.h (waitq): Declare structure here.

(_cygtls::wq): Declare.
* cygtls.cc (_cygtls::fixup_after_fork): Clear wq.thread_ev to avoid using an
invalid event handle in forked process.
* dcrt0.cc (waitq_storage): Delete.
(threadstuff): Remove waitq_storage.
* perthread.h (per_thread_waitq): Delete.
(waitq_storage): Delete declaration.
* sigproc.cc (sigproc_init): Remove perthread waitq consideration.
* sigproc.h (waitq): Delete declaration.
* wait.cc (wait4): Use _my_tls waitq structure rather than per_thread.
* cygtls.h (_cygtls::newmask): Delete member.
(_cygtls::deltamask): New member.
* gendef (_sigdelayed): Replace the call to set_process_mask by a call to
set_process_mask_delta.
* exceptions.cc (handle_sigsuspend): Do not filter tempmask.  Or
SIG_NONMASKABLE in deltamask as a flag.
(_cygtls::interrupt_setup): Set deltamask only.
(set_process_mask_delta): New function.
(_cygtls::call_signal_handler): Replace the first call to set_process_mask by a
call to set_process_mask_delta.
* tlsoffsets.h: Regenerate.
This commit is contained in:
Christopher Faylor 2004-03-12 03:09:28 +00:00
parent 7ea8e226ee
commit 9863b78e7b
11 changed files with 134 additions and 109 deletions

View File

@ -1,3 +1,31 @@
2004-03-11 Christopher Faylor <cgf@redhat.com>
* cygtls.h (waitq): Declare structure here.
(_cygtls::wq): Declare.
* cygtls.cc (_cygtls::fixup_after_fork): Clear wq.thread_ev to avoid
using an invalid event handle in forked process.
* dcrt0.cc (waitq_storage): Delete.
(threadstuff): Remove waitq_storage.
* perthread.h (per_thread_waitq): Delete.
(waitq_storage): Delete declaration.
* sigproc.cc (sigproc_init): Remove perthread waitq consideration.
* sigproc.h (waitq): Delete declaration.
* wait.cc (wait4): Use _my_tls waitq structure rather than per_thread.
2004-02-11 Pierre Humblet <pierre.humblet@ieee.org>
* cygtls.h (_cygtls::newmask): Delete member.
(_cygtls::deltamask): New member.
* gendef (_sigdelayed): Replace the call to set_process_mask by a call
to set_process_mask_delta.
* exceptions.cc (handle_sigsuspend): Do not filter tempmask. Or
SIG_NONMASKABLE in deltamask as a flag.
(_cygtls::interrupt_setup): Set deltamask only.
(set_process_mask_delta): New function.
(_cygtls::call_signal_handler): Replace the first call to
set_process_mask by a call to set_process_mask_delta.
* tlsoffsets.h: Regenerate.
2004-03-11 Christopher Faylor <cgf@redhat.com>
* cygtls.cc (_cygtls::fixup_after_fork): Remove unneeded setting of

View File

@ -139,6 +139,7 @@ void
_cygtls::fixup_after_fork ()
{
sig = stacklock = 0;
wq.thread_ev = NULL;
stackptr = stack + 1; // FIXME?
#ifdef DEBUGGING
memset (stackptr, 0, sizeof (stack) - sizeof (stack[0]));

View File

@ -85,9 +85,20 @@ struct _local_storage
char signamebuf[sizeof ("Unknown signal 4294967295 ")];
};
/* Please keep this file simple. Changes to the below structure may require
acompanying changes to the very simple parser in the perl script
'gentls_offsets' (<<-- start parsing here). */
typedef struct struct_waitq
{
int pid;
int options;
int status;
HANDLE ev;
void *rusage; /* pointer to potential rusage */
struct struct_waitq *next;
HANDLE thread_ev;
} waitq;
/* Changes to the below structure may require acompanying changes to the very
simple parser in the perl script 'gentls_offsets' (<<-- start parsing here).
*/
typedef __uint32_t __stack_t;
struct _cygtls
@ -96,7 +107,7 @@ struct _cygtls
int saved_errno;
int sa_flags;
sigset_t oldmask;
sigset_t newmask;
sigset_t deltamask;
HANDLE event;
int *errno_addr;
unsigned initialized;
@ -108,6 +119,7 @@ struct _cygtls
struct pthread *tid;
struct _reent local_clib;
struct _local_storage locals;
waitq wq;
struct _cygtls *prev, *next;
__stack_t *stackptr;
int sig;

View File

@ -44,12 +44,11 @@ details. */
HANDLE NO_COPY hMainProc = (HANDLE) -1;
HANDLE NO_COPY hMainThread;
per_thread_waitq NO_COPY waitq_storage;
#ifdef NEWVFORK
per_thread_vfork NO_COPY vfork_storage;
#endif
per_thread NO_COPY *threadstuff[] = {&waitq_storage,
per_thread NO_COPY *threadstuff[] = {
#ifdef NEWVFORK
&vfork_storage,
#endif

View File

@ -570,8 +570,7 @@ handle_sigsuspend (sigset_t tempmask)
{
sigset_t oldmask = myself->getsigmask (); // Remember for restoration
// Let signals we're interested in through.
set_signal_mask (tempmask &= ~SIG_NONMASKABLE, oldmask);
set_signal_mask (tempmask, oldmask);
sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
pthread_testcancel ();
@ -581,8 +580,9 @@ handle_sigsuspend (sigset_t tempmask)
/* A signal dispatch function will have been added to our stack and will
be hit eventually. Set the old mask to be restored when the signal
handler returns. */
handler returns and indicate its presence by modifying deltamask. */
_my_tls.deltamask |= SIG_NONMASKABLE;
_my_tls.oldmask = oldmask; // Will be restored by signal handler
return -1;
}
@ -671,8 +671,7 @@ void __stdcall
_cygtls::interrupt_setup (int sig, void *handler, struct sigaction& siga)
{
push ((__stack_t) sigdelayed, false);
oldmask = myself->getsigmask ();
newmask = oldmask | siga.sa_mask | SIGTOMASK (sig);
deltamask = (siga.sa_mask | SIGTOMASK (sig)) & ~SIG_NONMASKABLE;
sa_flags = siga.sa_flags;
func = (void (*) (int)) handler;
saved_errno = -1; // Flag: no errno to save
@ -900,6 +899,27 @@ sighold (int sig)
return 0;
}
/* Update the signal mask for this process
and return the old mask.
Called from sigdelayed */
extern "C" sigset_t
set_process_mask_delta ()
{
mask_sync->acquire (INFINITE);
sigset_t newmask, oldmask;
if (_my_tls.deltamask & SIG_NONMASKABLE)
oldmask = _my_tls.oldmask; /* from handle_sigsuspend */
else
oldmask = myself->getsigmask ();
newmask = (oldmask | _my_tls.deltamask) & ~SIG_NONMASKABLE;
sigproc_printf ("oldmask %p, newmask %p, deltamask %p", oldmask, newmask,
_my_tls.deltamask);
myself->setsigmask (newmask);
mask_sync->release ();
return oldmask;
}
/* Set the signal mask for this process.
Note that some signals are unmaskable, as in UNIX. */
extern "C" void __stdcall
@ -1152,14 +1172,13 @@ _cygtls::call_signal_handler ()
(void) pop ();
reset_signal_arrived ();
sigset_t this_oldmask = oldmask;
sigset_t this_oldmask = set_process_mask_delta ();
int this_errno = saved_errno;
set_process_mask (newmask);
incyg--;
sig = 0;
sigfunc (thissig);
incyg++;
set_process_mask (this_oldmask);
set_signal_mask (this_oldmask);
if (this_errno >= 0)
set_errno (this_errno);
}

View File

@ -190,15 +190,13 @@ _sigdelayed:
movl %fs:4,%ebx
incl $tls::incyg(%ebx)
pushl $tls::saved_errno(%ebx) # saved errno
pushl $tls::oldmask(%ebx) # oldmask
call _set_process_mask_delta
pushl %eax
pushl $tls::sig(%ebx) # signal argument
pushl \$_sigreturn
call _reset_signal_arrived\@0
pushl $tls::func(%ebx) # signal func
pushl $tls::newmask(%ebx) # newmask - eaten by set_process_mask
call _set_process_mask\@4
cmpl \$0,$tls::threadkill(%ebx)#pthread_kill signal?
jnz 4f #yes. Callee clears signal number
movl \$0,$tls::sig(%ebx) # zero the signal number as a

View File

@ -34,15 +34,6 @@ public:
}
};
class per_thread_waitq : public per_thread
{
public:
per_thread_waitq () : per_thread (0) {}
void *get () {return (waitq *) per_thread::get ();}
void *create () {return (waitq *) per_thread::create ();}
size_t size () {return sizeof (waitq);}
};
#ifdef NEED_VFORK
#include "cygtls.h"
#endif
@ -92,6 +83,4 @@ extern vfork_save *main_vfork;
#endif
#endif /*NEWVFORK*/
extern per_thread_waitq waitq_storage;
extern per_thread *threadstuff[];

View File

@ -109,7 +109,6 @@ Static char czombies[(NZOMBIES + 1) * sizeof (pinfo)]; // All my deceased child
#define zombies ((pinfo *) czombies)
Static waitq waitq_head = {0, 0, 0, 0, 0, 0, 0};// Start of queue for wait'ing threads
Static waitq waitq_main; // Storage for main thread
muto NO_COPY *sync_proc_subproc = NULL; // Control access to subproc stuff
@ -604,18 +603,6 @@ sigproc_init ()
hwait_sig = new cygthread (wait_sig, cygself, "sig");
hwait_sig->zap_h ();
/* Initialize waitq structure for main thread. A waitq structure is
* allocated for each thread that executes a wait to allow multiple threads
* to perform waits. Pre-allocate a waitq structure for the main thread.
*/
waitq *w;
if ((w = (waitq *)waitq_storage.get ()) == NULL)
{
w = &waitq_main;
waitq_storage.set (w);
}
memset (w, 0, sizeof *w); // Just to be safe
global_sigs[SIGSTOP].sa_flags = SA_RESTART | SA_NODEFER;
sigproc_printf ("process/signal handling enabled(%x)", myself->process_state);
return;

View File

@ -39,17 +39,6 @@ enum procstuff
PROC_NOTHING = 5 // nothing, really
};
typedef struct struct_waitq
{
int pid;
int options;
int status;
HANDLE ev;
void *rusage; /* pointer to potential rusage */
struct struct_waitq *next;
HANDLE thread_ev;
} waitq;
struct sigpacket
{
siginfo_t si;

View File

@ -1,105 +1,109 @@
//;# autogenerated: Do not edit.
//; $tls::sizeof__cygtls = 3748;
//; $tls::func = -3748;
//; $tls::sizeof__cygtls = 3776;
//; $tls::func = -3776;
//; $tls::pfunc = 0;
//; $tls::saved_errno = -3744;
//; $tls::saved_errno = -3772;
//; $tls::psaved_errno = 4;
//; $tls::sa_flags = -3740;
//; $tls::sa_flags = -3768;
//; $tls::psa_flags = 8;
//; $tls::oldmask = -3736;
//; $tls::oldmask = -3764;
//; $tls::poldmask = 12;
//; $tls::newmask = -3732;
//; $tls::pnewmask = 16;
//; $tls::event = -3728;
//; $tls::deltamask = -3760;
//; $tls::pdeltamask = 16;
//; $tls::event = -3756;
//; $tls::pevent = 20;
//; $tls::errno_addr = -3724;
//; $tls::errno_addr = -3752;
//; $tls::perrno_addr = 24;
//; $tls::initialized = -3720;
//; $tls::initialized = -3748;
//; $tls::pinitialized = 28;
//; $tls::sigmask = -3716;
//; $tls::sigmask = -3744;
//; $tls::psigmask = 32;
//; $tls::sigwait_mask = -3712;
//; $tls::sigwait_mask = -3740;
//; $tls::psigwait_mask = 36;
//; $tls::sigwait_info = -3708;
//; $tls::sigwait_info = -3736;
//; $tls::psigwait_info = 40;
//; $tls::threadkill = -3704;
//; $tls::threadkill = -3732;
//; $tls::pthreadkill = 44;
//; $tls::infodata = -3700;
//; $tls::infodata = -3728;
//; $tls::pinfodata = 48;
//; $tls::tid = -3552;
//; $tls::tid = -3580;
//; $tls::ptid = 196;
//; $tls::local_clib = -3548;
//; $tls::local_clib = -3576;
//; $tls::plocal_clib = 200;
//; $tls::locals = -2620;
//; $tls::locals = -2648;
//; $tls::plocals = 1128;
//; $tls::wq = -1080;
//; $tls::pwq = 2696;
//; $tls::prev = -1052;
//; $tls::pprev = 2696;
//; $tls::pprev = 2724;
//; $tls::next = -1048;
//; $tls::pnext = 2700;
//; $tls::pnext = 2728;
//; $tls::stackptr = -1044;
//; $tls::pstackptr = 2704;
//; $tls::pstackptr = 2732;
//; $tls::sig = -1040;
//; $tls::psig = 2708;
//; $tls::psig = 2736;
//; $tls::incyg = -1036;
//; $tls::pincyg = 2712;
//; $tls::pincyg = 2740;
//; $tls::spinning = -1032;
//; $tls::pspinning = 2716;
//; $tls::pspinning = 2744;
//; $tls::stacklock = -1028;
//; $tls::pstacklock = 2720;
//; $tls::pstacklock = 2748;
//; $tls::stack = -1024;
//; $tls::pstack = 2724;
//; $tls::pstack = 2752;
//; $tls::padding = 0;
//; $tls::ppadding = 3748;
//; $tls::ppadding = 3776;
//; __DATA__
#define tls_func (-3748)
#define tls_func (-3776)
#define tls_pfunc (0)
#define tls_saved_errno (-3744)
#define tls_saved_errno (-3772)
#define tls_psaved_errno (4)
#define tls_sa_flags (-3740)
#define tls_sa_flags (-3768)
#define tls_psa_flags (8)
#define tls_oldmask (-3736)
#define tls_oldmask (-3764)
#define tls_poldmask (12)
#define tls_newmask (-3732)
#define tls_pnewmask (16)
#define tls_event (-3728)
#define tls_deltamask (-3760)
#define tls_pdeltamask (16)
#define tls_event (-3756)
#define tls_pevent (20)
#define tls_errno_addr (-3724)
#define tls_errno_addr (-3752)
#define tls_perrno_addr (24)
#define tls_initialized (-3720)
#define tls_initialized (-3748)
#define tls_pinitialized (28)
#define tls_sigmask (-3716)
#define tls_sigmask (-3744)
#define tls_psigmask (32)
#define tls_sigwait_mask (-3712)
#define tls_sigwait_mask (-3740)
#define tls_psigwait_mask (36)
#define tls_sigwait_info (-3708)
#define tls_sigwait_info (-3736)
#define tls_psigwait_info (40)
#define tls_threadkill (-3704)
#define tls_threadkill (-3732)
#define tls_pthreadkill (44)
#define tls_infodata (-3700)
#define tls_infodata (-3728)
#define tls_pinfodata (48)
#define tls_tid (-3552)
#define tls_tid (-3580)
#define tls_ptid (196)
#define tls_local_clib (-3548)
#define tls_local_clib (-3576)
#define tls_plocal_clib (200)
#define tls_locals (-2620)
#define tls_locals (-2648)
#define tls_plocals (1128)
#define tls_wq (-1080)
#define tls_pwq (2696)
#define tls_prev (-1052)
#define tls_pprev (2696)
#define tls_pprev (2724)
#define tls_next (-1048)
#define tls_pnext (2700)
#define tls_pnext (2728)
#define tls_stackptr (-1044)
#define tls_pstackptr (2704)
#define tls_pstackptr (2732)
#define tls_sig (-1040)
#define tls_psig (2708)
#define tls_psig (2736)
#define tls_incyg (-1036)
#define tls_pincyg (2712)
#define tls_pincyg (2740)
#define tls_spinning (-1032)
#define tls_pspinning (2716)
#define tls_pspinning (2744)
#define tls_stacklock (-1028)
#define tls_pstacklock (2720)
#define tls_pstacklock (2748)
#define tls_stack (-1024)
#define tls_pstack (2724)
#define tls_pstack (2752)
#define tls_padding (0)
#define tls_ppadding (3748)
#define tls_ppadding (3776)

View File

@ -47,8 +47,8 @@ extern "C" pid_t
wait4 (int intpid, int *status, int options, struct rusage *r)
{
int res;
waitq *w;
HANDLE waitfor;
waitq *w;
pthread_testcancel ();
@ -65,8 +65,7 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
if (r)
memset (r, 0, sizeof (*r));
if ((w = (waitq *) waitq_storage.get ()) == NULL)
w = (waitq *) waitq_storage.create ();
w = &_my_tls.wq;
w->pid = intpid;
w->options = options;