* child_info.h (cygheap_exec_info::sigmask): Declare new field.
* cygheap.cc (init_cygheap::find_tls): Rename threadlist_ix -> ix. Only take one pass through thread list, looking for eligible threads to signal. Set a new param indicating that function has found a sigwait* mask. * cygheap.h (init_cygheap::find_tls): Reflect new parameter. * dcrt0.cc (parent_sigmask): New variable. (child_info_spawn::handle_spawn): Save parent's signal mask here. (dll_crt0_1): Restore parent's signal mask to tls sigmask as appropriate. Call sig_dispatch_pending to flush signal queue when we can finally do something with signals. * exceptions.cc (sigpacket::process): Avoid attempting to handle signals if we haven't finished initializing. Rely on the fact that find_tls will do mask checking and don't do it again. Delete ill-named 'dummy' variable. * sigproc.cc (cygheap_exec_info::alloc): Save calling thread's signal mask in new sigmask field. (wait_sig): Try to debug when WFSO fails and DEBUGGING is defined. * thread.cc (pthread::set_tls_self_pointer): Make this a true automatic method rather than inexplicably relying on a thread parameter. (pthread::thread_init_wrapper): Accommodate set_tls_self_pointer change to non-static. Initialize sigmask before setting tid or suffer signal races. * ehread.h (pthread::set_tls_self_pointer): Make non-static, delete parameter.
This commit is contained in:
@@ -338,7 +338,7 @@ pthread::init_mainthread ()
|
||||
api_fatal ("failed to create mainthread object");
|
||||
}
|
||||
|
||||
set_tls_self_pointer (thread);
|
||||
thread->set_tls_self_pointer ();
|
||||
thread->thread_id = GetCurrentThreadId ();
|
||||
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
|
||||
GetCurrentProcess (), &thread->win32_obj_id,
|
||||
@@ -357,16 +357,16 @@ pthread::self ()
|
||||
if (!thread)
|
||||
{
|
||||
thread = pthread_null::get_null_pthread ();
|
||||
set_tls_self_pointer (thread);
|
||||
thread->set_tls_self_pointer ();
|
||||
}
|
||||
return thread;
|
||||
}
|
||||
|
||||
void
|
||||
pthread::set_tls_self_pointer (pthread *thread)
|
||||
pthread::set_tls_self_pointer ()
|
||||
{
|
||||
thread->cygtls = &_my_tls;
|
||||
_my_tls.tid = thread;
|
||||
cygtls = &_my_tls;
|
||||
_my_tls.tid = this;
|
||||
}
|
||||
|
||||
List<pthread> pthread::threads;
|
||||
@@ -1912,14 +1912,14 @@ DWORD WINAPI
|
||||
pthread::thread_init_wrapper (void *arg)
|
||||
{
|
||||
pthread *thread = (pthread *) arg;
|
||||
set_tls_self_pointer (thread);
|
||||
_my_tls.sigmask = thread->parent_sigmask;
|
||||
thread->set_tls_self_pointer ();
|
||||
|
||||
thread->mutex.lock ();
|
||||
|
||||
// if thread is detached force cleanup on exit
|
||||
if (thread->attr.joinable == PTHREAD_CREATE_DETACHED && thread->joiner == NULL)
|
||||
thread->joiner = thread;
|
||||
_my_tls.sigmask = thread->parent_sigmask;
|
||||
thread->mutex.unlock ();
|
||||
|
||||
debug_printf ("tid %p", &_my_tls);
|
||||
|
Reference in New Issue
Block a user