OSDN Git Service

bionic: on pthread_join(), avoid extra check in case we find the thread
authorAndré Goddard Rosa <andre.goddard@gmail.com>
Fri, 5 Feb 2010 18:21:07 +0000 (16:21 -0200)
committerAndré Goddard Rosa <andre.goddard@gmail.com>
Fri, 5 Feb 2010 18:21:07 +0000 (16:21 -0200)
... by using similar logic as used in pthread_detach().

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
libc/bionic/pthread.c

index 8171aac..7d4056d 100644 (file)
@@ -597,13 +597,12 @@ int pthread_join(pthread_t thid, void ** ret_val)
 
     for (thread = gThreadList; thread != NULL; thread = thread->next)
         if (thread == (pthread_internal_t*)thid)
-            break;
+            goto FoundIt;
 
-    if (!thread) {
-        pthread_mutex_unlock(&gThreadListLock);
-        return ESRCH;
-    }
+    pthread_mutex_unlock(&gThreadListLock);
+    return ESRCH;
 
+FoundIt:
     if (thread->attr.flags & PTHREAD_ATTR_FLAG_DETACHED) {
         pthread_mutex_unlock(&gThreadListLock);
         return EINVAL;