OSDN Git Service

Properly detect timeout in pthread_mutex_lock_timeout_np_impl
authorKen Mixter <kmixter@google.com>
Tue, 17 Dec 2013 20:40:08 +0000 (12:40 -0800)
committerKen Mixter <kmixter@google.com>
Tue, 17 Dec 2013 22:26:01 +0000 (14:26 -0800)
Previously we were checking against a positive errno which
would not be returned from a system call.

Change-Id: I8e3a36f6fbf5ccc2191a152a1def37e2d6f93124

libc/bionic/pthread_mutex.cpp

index 1010f11..4a11747 100644 (file)
@@ -800,7 +800,7 @@ int pthread_mutex_lock_timeout_np_impl(pthread_mutex_t *mutex, unsigned msecs)
          * thread.
          */
         if (MUTEX_STATE_BITS_IS_LOCKED_CONTENDED(mvalue)) {
-            if (__futex_wait_ex(&mutex->value, shared, mvalue, &ts) == ETIMEDOUT) {
+            if (__futex_wait_ex(&mutex->value, shared, mvalue, &ts) == (-ETIMEDOUT)) {
                 return EBUSY;
             }
             mvalue = mutex->value;