diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-05-23 19:49:39 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-05-23 19:49:39 +0000 |
commit | 9cbf10a06e6c3c1dffe43ca6c642bb5f7c5e8224 (patch) | |
tree | 71a0daa230beaba77a4960c42eab65034c4cc6fc | |
parent | 2b165a453ea7b7ded24c2df03b2673f630f32259 (diff) | |
download | cygnal-9cbf10a06e6c3c1dffe43ca6c642bb5f7c5e8224.tar.gz cygnal-9cbf10a06e6c3c1dffe43ca6c642bb5f7c5e8224.tar.bz2 cygnal-9cbf10a06e6c3c1dffe43ca6c642bb5f7c5e8224.zip |
* thread.cc (__cygwin_lock_lock): Take null thread at process startup
into account.
(__cygwin_lock_trylock): Ditto.
(__cygwin_lock_unlock): Ditto.
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/thread.cc | 32 |
2 files changed, 28 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7b4ae8d80..53388bd88 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,12 @@ 2012-05-23 Corinna Vinschen <corinna@vinschen.de> + * thread.cc (__cygwin_lock_lock): Take null thread at process startup + into account. + (__cygwin_lock_trylock): Ditto. + (__cygwin_lock_unlock): Ditto. + +2012-05-23 Corinna Vinschen <corinna@vinschen.de> + * thread.cc (pthread::cancel): Re-allow asynchronous cancellation from Cygwin code since it looks like the problem is Windows only. diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 72806b8de..d52a85121 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -144,9 +144,12 @@ __cygwin_lock_lock (_LOCK_T *lock) { paranoid_printf ("threadcount %d. locking", MT_INTERFACE->threadcount); #ifdef WORKAROUND_NEWLIB - __cygwin_lock_handler *cleanup - = new __cygwin_lock_handler (__cygwin_lock_cleanup, lock); - pthread::self ()->push_cleanup_handler (cleanup); + if (pthread::self () != pthread_null::get_null_pthread ()) + { + __cygwin_lock_handler *cleanup + = new __cygwin_lock_handler (__cygwin_lock_cleanup, lock); + pthread::self ()->push_cleanup_handler (cleanup); + } #endif /* WORKAROUND_NEWLIB */ pthread_mutex_lock ((pthread_mutex_t*) lock); } @@ -155,12 +158,18 @@ extern "C" int __cygwin_lock_trylock (_LOCK_T *lock) { #ifdef WORKAROUND_NEWLIB - __cygwin_lock_handler *cleanup - = new __cygwin_lock_handler (__cygwin_lock_cleanup, lock); - pthread::self ()->push_cleanup_handler (cleanup); + __cygwin_lock_handler *cleanup = NULL; + if (pthread::self () != pthread_null::get_null_pthread ()) + { + cleanup = new __cygwin_lock_handler (__cygwin_lock_cleanup, lock); + pthread::self ()->push_cleanup_handler (cleanup); + } int ret = pthread_mutex_trylock ((pthread_mutex_t*) lock); - if (ret) - pthread::self ()->pop_cleanup_handler (0); + 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); @@ -171,10 +180,11 @@ extern "C" void __cygwin_lock_unlock (_LOCK_T *lock) { #ifdef WORKAROUND_NEWLIB - pthread::self ()->pop_cleanup_handler (1); -#else - pthread_mutex_unlock ((pthread_mutex_t*) lock); + if (pthread::self () != pthread_null::get_null_pthread ()) + pthread::self ()->pop_cleanup_handler (1); + else #endif /* WORKAROUND_NEWLIB */ + pthread_mutex_unlock ((pthread_mutex_t*) lock); paranoid_printf ("threadcount %d. unlocked", MT_INTERFACE->threadcount); } |