diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7dedfe3c7..ae47324df 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2003-05-15 Thomas Pfaff + + * thread.h (pthread::init_mainthread): Remove function parameter. + (MTinterface::Init): Ditto. + * thread.cc (MTinterface::Init): Remove function parameter. + Always initialize reent_key. + (pthread::init_mainthread): Remove function parameter. + (MTinterface::fixup_after_fork): Fix pthread::init_mainthread call. + * dcrt0.cc (dll_crt_0_1) Fix calls to MTinterface::Init and + pthread::init_mainthread. + Call pthread::init_mainthread only when not forked. + 2003-05-15 Corinna Vinschen * fhandler_proc.cc (format_proc_meminfo): Make swap memory output diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 9ae2e5345..a11b34277 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -565,7 +565,7 @@ dll_crt0_1 () _impure_ptr = &reent_data; user_data->resourcelocks->Init (); - user_data->threadinterface->Init (user_data->forkee); + user_data->threadinterface->Init (); mainthread.init ("mainthread"); // For use in determining if signals // should be blocked. @@ -631,7 +631,10 @@ dll_crt0_1 () ProtectHandle (hMainThread); cygthread::init (); - pthread::init_mainthread (!user_data->forkee); + /* Initialize pthread mainthread when not forked and it is save to call new, + otherwise it is reinitalized in fixup_after_fork */ + if (!user_data->forkee) + pthread::init_mainthread (); /* Initialize debug muto, if DLL is built with --enable-debugging. Need to do this before any helper threads start. */ diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index de5392f84..0321ea47b 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -188,14 +188,12 @@ ResourceLocks::Delete () } void -MTinterface::Init (int forked) +MTinterface::Init () { reents._clib = _impure_ptr; reents._winsup = &winsup_reent; winsup_reent._process_logmask = LOG_UPTO (LOG_DEBUG); - - if (!forked) - reent_key.set (&reents); + reent_key.set (&reents); pthread_mutex::init_mutex (); pthread_cond::init_mutex (); @@ -215,7 +213,7 @@ MTinterface::fixup_after_fork (void) pthread_key::fixup_after_fork (); threadcount = 1; - pthread::init_mainthread (true); + pthread::init_mainthread (); pthread_mutex::fixup_after_fork (); pthread_cond::fixup_after_fork (); @@ -227,11 +225,8 @@ MTinterface::fixup_after_fork (void) /* static methods */ void -pthread::init_mainthread (bool do_init) +pthread::init_mainthread () { - if (!do_init) - return; - pthread *thread = get_tls_self_pointer (); if (!thread) { diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h index e162b32a0..55d94157b 100644 --- a/winsup/cygwin/thread.h +++ b/winsup/cygwin/thread.h @@ -401,7 +401,7 @@ public: pthread (); virtual ~pthread (); - static void init_mainthread (bool); + static void init_mainthread (); static bool is_good_object(pthread_t const *); static void atforkprepare(); static void atforkparent(); @@ -679,7 +679,7 @@ public: pthread_key reent_key; pthread_key thread_self_key; - void Init (int); + void Init (); void fixup_before_fork (void); void fixup_after_fork (void);