]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Made DRD_(thread_set_pthreadid)() idempotent.
authorBart Van Assche <bvanassche@acm.org>
Thu, 23 Apr 2009 17:12:39 +0000 (17:12 +0000)
committerBart Van Assche <bvanassche@acm.org>
Thu, 23 Apr 2009 17:12:39 +0000 (17:12 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9590

drd/drd_thread.c

index 2b692b143db1879c0244acc7f5814b8f7e4eb2d2..cf22859a53afebe1b23eb2bf21b70d0bd652312e 100644 (file)
@@ -451,12 +451,19 @@ void DRD_(thread_pre_cancel)(const DrdThreadId tid)
    DRD_(g_threadinfo)[tid].synchr_nesting = 0;
 }
 
-/** Store the POSIX thread ID for the specified thread. */
+/**
+ * Store the POSIX thread ID for the specified thread.
+ *
+ * @note This function can be called two times for the same thread -- see also
+ * the comment block preceding the pthread_create() wrapper in
+ * drd_pthread_intercepts.c.
+ */
 void DRD_(thread_set_pthreadid)(const DrdThreadId tid, const PThreadId ptid)
 {
    tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
              && tid != DRD_INVALID_THREADID);
-   tl_assert(DRD_(g_threadinfo)[tid].pt_threadid == INVALID_POSIX_THREADID);
+   tl_assert(DRD_(g_threadinfo)[tid].pt_threadid == INVALID_POSIX_THREADID
+             || DRD_(g_threadinfo)[tid].pt_threadid == ptid);
    tl_assert(ptid != INVALID_POSIX_THREADID);
    DRD_(g_threadinfo)[tid].posix_thread_exists = True;
    DRD_(g_threadinfo)[tid].pt_threadid         = ptid;