fix logic for when wakeup is not desired on cond bcast
authorRich Felker <dalias@aerifal.cx>
Sun, 25 Sep 2011 06:56:01 +0000 (02:56 -0400)
committerRich Felker <dalias@aerifal.cx>
Sun, 25 Sep 2011 06:56:01 +0000 (02:56 -0400)
somehow i forgot that normal-type mutexes don't store the owner tid.

src/thread/pthread_cond_broadcast.c

index 3daa78174b99b77473542cf42735c905c4072d97..7e5ea91c507401525d4616fe0154b8fb01fe39b8 100644 (file)
@@ -37,10 +37,11 @@ int pthread_cond_broadcast(pthread_cond_t *c)
                a_fetch_add(&m->_m_waiters, -w);
        }
 
-       /* Perform the futex requeue, waking one waiter if and only if
-        * the calling thread does not hold the mutex. */
+       /* Perform the futex requeue, waking one waiter unless we know
+        * that the calling thread holds the mutex. */
        __syscall(SYS_futex, &c->_c_block, FUTEX_REQUEUE,
-               m->_m_lock!=pthread_self()->tid, INT_MAX, &m->_m_lock);
+               !m->_m_type || (m->_m_lock&INT_MAX)!=pthread_self()->tid,
+               INT_MAX, &m->_m_lock);
 
        unlock(c);
        return 0;