From: Tom Hughes Date: Sat, 16 Oct 2004 16:50:14 +0000 (+0000) Subject: When returning from handling a signal check whether any mutex that the X-Git-Tag: svn/VALGRIND_3_0_0~1515 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=23cff452d7f33bcb4c3a7ff0e2de6d47d5379939;p=thirdparty%2Fvalgrind.git When returning from handling a signal check whether any mutex that the thread was waiting on has been unlocked while the signal handler was running and resume the thread if it was. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2779 --- diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 39ad8372f0..5ce5bb3aa5 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -464,6 +464,18 @@ void handle_signal_return ( ThreadId tid ) maybe_rendezvous_joiners_and_joinees(); } + /* If we were interrupted while waiting on a mutex then check that + it hasn't been unlocked while we were busy handling the signal. */ + if (VG_(threads)[tid].status == VgTs_WaitMX && + VG_(threads)[tid].associated_mx->__vg_m_count == 0) { + vg_pthread_mutex_t* mutex = VG_(threads)[tid].associated_mx; + mutex->__vg_m_count = 1; + mutex->__vg_m_owner = (/*_pthread_descr*/void*)tid; + VG_(threads)[tid].status = VgTs_Runnable; + VG_(threads)[tid].associated_mx = NULL; + /* m_edx already holds pth_mx_lock() success (0) */ + } + if (restart_blocked_syscalls) /* Easy; we don't have to do anything. */ return;