Do not report deadlock on relocking a recursive mutex; lock count not implemented yet
[c11tester.git] / threads.cc
index 8b55a91b186b61534ec124ca2a990283c11a3ffb..ee0df19ca338bd20e2a3dc0e4bd85b00ab059354 100644 (file)
@@ -490,6 +490,14 @@ Thread * Thread::waiting_on() const
 bool Thread::is_waiting_on(const Thread *t) const
 {
        Thread *wait;
+
+       // One thread relocks a recursive mutex
+       if (waiting_on() == t && pending->is_lock()) {
+               int mutex_type = pending->get_mutex()->get_state()->type;
+               if (mutex_type == PTHREAD_MUTEX_RECURSIVE)
+                       return false;
+       }
+
        for (wait = waiting_on();wait != NULL;wait = wait->waiting_on())
                if (wait == t)
                        return true;