* thread.cc (__cygwin_lock_lock): Replace null thread check with test

for cygwin_finished_initializing to handle process startup.
	(__cygwin_lock_trylock): Ditto.
	(__cygwin_lock_unlock): Ditto.
This commit is contained in:
Corinna Vinschen 2012-05-24 14:17:51 +00:00
parent a7a7311974
commit 32c02f191b
2 changed files with 21 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2012-05-24 Corinna Vinschen <corinna@vinschen.de>
* thread.cc (__cygwin_lock_lock): Replace null thread check with test
for cygwin_finished_initializing to handle process startup.
(__cygwin_lock_trylock): Ditto.
(__cygwin_lock_unlock): Ditto.
2012-05-23 Corinna Vinschen <corinna@vinschen.de> 2012-05-23 Corinna Vinschen <corinna@vinschen.de>
* thread.cc (__cygwin_lock_lock): Take null thread at process startup * thread.cc (__cygwin_lock_lock): Take null thread at process startup

View File

@ -144,7 +144,7 @@ __cygwin_lock_lock (_LOCK_T *lock)
{ {
paranoid_printf ("threadcount %d. locking", MT_INTERFACE->threadcount); paranoid_printf ("threadcount %d. locking", MT_INTERFACE->threadcount);
#ifdef WORKAROUND_NEWLIB #ifdef WORKAROUND_NEWLIB
if (pthread::self () != pthread_null::get_null_pthread ()) if (cygwin_finished_initializing)
{ {
__cygwin_lock_handler *cleanup __cygwin_lock_handler *cleanup
= new __cygwin_lock_handler (__cygwin_lock_cleanup, lock); = new __cygwin_lock_handler (__cygwin_lock_cleanup, lock);
@ -158,29 +158,29 @@ extern "C" int
__cygwin_lock_trylock (_LOCK_T *lock) __cygwin_lock_trylock (_LOCK_T *lock)
{ {
#ifdef WORKAROUND_NEWLIB #ifdef WORKAROUND_NEWLIB
__cygwin_lock_handler *cleanup = NULL; if (cygwin_finished_initializing)
if (pthread::self () != pthread_null::get_null_pthread ())
{ {
cleanup = new __cygwin_lock_handler (__cygwin_lock_cleanup, lock); __cygwin_lock_handler *cleanup
= new __cygwin_lock_handler (__cygwin_lock_cleanup, lock);
pthread::self ()->push_cleanup_handler (cleanup); pthread::self ()->push_cleanup_handler (cleanup);
int ret = pthread_mutex_trylock ((pthread_mutex_t*) lock);
if (ret)
{
pthread::self ()->pop_cleanup_handler (0);
delete cleanup;
}
return ret;
} }
int ret = pthread_mutex_trylock ((pthread_mutex_t*) lock); else
if (ret && pthread::self () != pthread_null::get_null_pthread ())
{
pthread::self ()->pop_cleanup_handler (0);
delete cleanup;
}
return ret;
#else
return pthread_mutex_trylock ((pthread_mutex_t*) lock);
#endif /* WORKAROUND_NEWLIB */ #endif /* WORKAROUND_NEWLIB */
return pthread_mutex_trylock ((pthread_mutex_t*) lock);
} }
extern "C" void extern "C" void
__cygwin_lock_unlock (_LOCK_T *lock) __cygwin_lock_unlock (_LOCK_T *lock)
{ {
#ifdef WORKAROUND_NEWLIB #ifdef WORKAROUND_NEWLIB
if (pthread::self () != pthread_null::get_null_pthread ()) if (cygwin_finished_initializing)
pthread::self ()->pop_cleanup_handler (1); pthread::self ()->pop_cleanup_handler (1);
else else
#endif /* WORKAROUND_NEWLIB */ #endif /* WORKAROUND_NEWLIB */