]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When returning from handling a signal check whether any mutex that the
authorTom Hughes <tom@compton.nu>
Sat, 16 Oct 2004 16:50:14 +0000 (16:50 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 16 Oct 2004 16:50:14 +0000 (16:50 +0000)
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

coregrind/vg_scheduler.c

index 39ad8372f052e6510e2358159653b1a4de8f945f..5ce5bb3aa5263a88dceb455e7e77e6000caf327e 100644 (file)
@@ -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;