* thread.cc (__cygwin_lock_lock): Take null thread at process startup
into account. (__cygwin_lock_trylock): Ditto. (__cygwin_lock_unlock): Ditto.
This commit is contained in:
parent
2b165a453e
commit
9cbf10a06e
@ -1,3 +1,10 @@
|
|||||||
|
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>
|
2012-05-23 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* thread.cc (pthread::cancel): Re-allow asynchronous cancellation from
|
* thread.cc (pthread::cancel): Re-allow asynchronous cancellation from
|
||||||
|
@ -144,9 +144,12 @@ __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
|
||||||
__cygwin_lock_handler *cleanup
|
if (pthread::self () != pthread_null::get_null_pthread ())
|
||||||
= new __cygwin_lock_handler (__cygwin_lock_cleanup, lock);
|
{
|
||||||
pthread::self ()->push_cleanup_handler (cleanup);
|
__cygwin_lock_handler *cleanup
|
||||||
|
= new __cygwin_lock_handler (__cygwin_lock_cleanup, lock);
|
||||||
|
pthread::self ()->push_cleanup_handler (cleanup);
|
||||||
|
}
|
||||||
#endif /* WORKAROUND_NEWLIB */
|
#endif /* WORKAROUND_NEWLIB */
|
||||||
pthread_mutex_lock ((pthread_mutex_t*) lock);
|
pthread_mutex_lock ((pthread_mutex_t*) lock);
|
||||||
}
|
}
|
||||||
@ -155,12 +158,18 @@ 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
|
__cygwin_lock_handler *cleanup = NULL;
|
||||||
= new __cygwin_lock_handler (__cygwin_lock_cleanup, lock);
|
if (pthread::self () != pthread_null::get_null_pthread ())
|
||||||
pthread::self ()->push_cleanup_handler (cleanup);
|
{
|
||||||
|
cleanup = new __cygwin_lock_handler (__cygwin_lock_cleanup, lock);
|
||||||
|
pthread::self ()->push_cleanup_handler (cleanup);
|
||||||
|
}
|
||||||
int ret = pthread_mutex_trylock ((pthread_mutex_t*) lock);
|
int ret = pthread_mutex_trylock ((pthread_mutex_t*) lock);
|
||||||
if (ret)
|
if (ret && pthread::self () != pthread_null::get_null_pthread ())
|
||||||
pthread::self ()->pop_cleanup_handler (0);
|
{
|
||||||
|
pthread::self ()->pop_cleanup_handler (0);
|
||||||
|
delete cleanup;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
return pthread_mutex_trylock ((pthread_mutex_t*) lock);
|
return pthread_mutex_trylock ((pthread_mutex_t*) lock);
|
||||||
@ -171,10 +180,11 @@ extern "C" void
|
|||||||
__cygwin_lock_unlock (_LOCK_T *lock)
|
__cygwin_lock_unlock (_LOCK_T *lock)
|
||||||
{
|
{
|
||||||
#ifdef WORKAROUND_NEWLIB
|
#ifdef WORKAROUND_NEWLIB
|
||||||
pthread::self ()->pop_cleanup_handler (1);
|
if (pthread::self () != pthread_null::get_null_pthread ())
|
||||||
#else
|
pthread::self ()->pop_cleanup_handler (1);
|
||||||
pthread_mutex_unlock ((pthread_mutex_t*) lock);
|
else
|
||||||
#endif /* WORKAROUND_NEWLIB */
|
#endif /* WORKAROUND_NEWLIB */
|
||||||
|
pthread_mutex_unlock ((pthread_mutex_t*) lock);
|
||||||
paranoid_printf ("threadcount %d. unlocked", MT_INTERFACE->threadcount);
|
paranoid_printf ("threadcount %d. unlocked", MT_INTERFACE->threadcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user