]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix another potentially-failing use of get_current_tid(), in
authorJulian Seward <jseward@acm.org>
Wed, 24 Nov 2004 21:24:24 +0000 (21:24 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 24 Nov 2004 21:24:24 +0000 (21:24 +0000)
proxy_sendsig().  Fixes the pth_blockesig regression test.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3100

coregrind/core.h
coregrind/vg_proxylwp.c
coregrind/vg_scheduler.c
coregrind/vg_signals.c

index 4921efd41428e9e56545a14d50612077ccdbb74c..eff0df0044b534fcb289e968cedddc33da8008ef 100644 (file)
@@ -1325,7 +1325,7 @@ extern void VG_(proxy_init)     ( void );
 extern void VG_(proxy_create)   ( ThreadId tid );
 extern void VG_(proxy_delete)   ( ThreadId tid, Bool force );
 extern void VG_(proxy_results)  ( void );
-extern void VG_(proxy_sendsig)  ( ThreadId tid, Int signo );
+extern void VG_(proxy_sendsig)  ( ThreadId fromTid, ThreadId toTid, Int signo );
 extern void VG_(proxy_setsigmask)(ThreadId tid);
 extern void VG_(proxy_sigack)   ( ThreadId tid, const vki_sigset_t *);
 extern void VG_(proxy_abort_syscall) ( ThreadId tid );
index 83ee91da7f16afce60cadf2be55d1e18492d47c1..5c92166e83373b7b96268807992e47cd2aba35df 100644 (file)
@@ -725,11 +725,14 @@ static Int proxylwp(void *v)
 }
 
 /* Send a signal to a proxy LWP */
-void VG_(proxy_sendsig)(ThreadId tid, Int sig)
+void VG_(proxy_sendsig)(ThreadId fromTid, ThreadId toTid, Int sig)
 {
-   ThreadState *tst = VG_(get_ThreadState)(tid);
-   ProxyLWP *proxy = tst->proxy;
-   Int lwp;
+   /* toTid must be genuine, but fromTid can be
+      VG_INVALID_THREADID. */
+   ThreadState* tst   = VG_(get_ThreadState)(toTid);
+   ProxyLWP*    proxy = tst->proxy;
+   Bool         signallingMyself;
+   Int          lwp;
 
    if (proxy == NULL)
       return;
@@ -748,18 +751,22 @@ void VG_(proxy_sendsig)(ThreadId tid, Int sig)
    /* If a thread is sending a signal to itself and the signal isn't
       blocked (ie, it will be delivered), wait until the signal
       message gets sent back, thus making the signal synchronous. */
+   signallingMyself 
+      = fromTid != VG_INVALID_THREADID
+        && fromTid == toTid;
+
    if (sig != 0 && 
        !VG_(is_sig_ign)(sig) &&
-       tid == VG_(get_current_tid)() && 
+       signallingMyself && 
        !VG_(sigismember)(&tst->eff_sig_mask, sig)) {
       /* If the LWP is actually blocked in a sigtimedwait, then it
         will eat the signal rather than make it pending and deliver
         it by the normal mechanism.  In this case, just wait for the
         syscall to dinish. */
       if (tst->status == VgTs_WaitSys && tst->syscallno == __NR_rt_sigtimedwait)
-        sys_wait_results(True, tid, PX_RunSyscall, True);
+        sys_wait_results(True, toTid, PX_RunSyscall, True);
       else
-        sys_wait_results(True, tid, PX_Signal, True);
+        sys_wait_results(True, toTid, PX_Signal, True);
    }
 }
 
index ffb09d7bdc5fe5c99451f5df172a0c0544bb5d74..00a7ed7b7bfa43e4698c6c4a67ceb870f0c123b7 100644 (file)
@@ -2689,7 +2689,7 @@ void do_pthread_kill ( ThreadId tid, /* me */
 
    tst = VG_(get_ThreadState)(thread);
    vg_assert(NULL != tst->proxy);
-   VG_(proxy_sendsig)(thread, sig);
+   VG_(proxy_sendsig)(tid/*from*/, thread/*to*/, sig);
    SET_PTHREQ_RETVAL(tid, 0);
 }
 
index 044e3b0fd05d452eb16efb03899f9de4df5305e4..4613afd957e18200802fcea69a600b575ee146eb 100644 (file)
@@ -1977,7 +1977,8 @@ void VG_(route_signals)(void)
          tst->sigqueue[tst->sigqueue_head] = siset[sigNo];
          tst->sigqueue_head = (tst->sigqueue_head + 1) % VG_N_SIGNALQUEUE;
          vg_assert(tst->sigqueue_head != tst->sigqueue_tail);
-        VG_(proxy_sendsig)(target, sigNo);
+        VG_(proxy_sendsig)(VG_INVALID_THREADID/*from*/,
+                            target/*to*/, sigNo);
         VG_(sigdelset)(&proc_pending, sigNo);
       }
    }