Let g_thread_list_lock only protect g_thread_list.
As glibc/netbsd don't protect access to thread struct members by a global
lock, we don't want to do it either. This change reduces the
responsibility of g_thread_list_lock to only protect g_thread_list.
Bug: 19636317
Change-Id: I897890710653dac165d8fa4452c7ecf74abdbf2b
diff --git a/libc/bionic/pthread_kill.cpp b/libc/bionic/pthread_kill.cpp
index 163317e..93513fa 100644
--- a/libc/bionic/pthread_kill.cpp
+++ b/libc/bionic/pthread_kill.cpp
@@ -30,26 +30,17 @@
#include <unistd.h>
#include "private/ErrnoRestorer.h"
-#include "pthread_accessor.h"
+#include "pthread_internal.h"
extern "C" int tgkill(int tgid, int tid, int sig);
int pthread_kill(pthread_t t, int sig) {
ErrnoRestorer errno_restorer;
- pthread_accessor thread(t);
- if (thread.get() == NULL) {
+ pthread_internal_t* thread = __pthread_internal_find(t);
+ if (thread == NULL) {
return ESRCH;
}
- // There's a race here, but it's one we share with all other C libraries.
- pid_t tid = thread->tid;
- thread.Unlock();
-
- int rc = tgkill(getpid(), tid, sig);
- if (rc == -1) {
- return errno;
- }
-
- return 0;
+ return (tgkill(getpid(), thread->tid, sig) == -1) ? errno : 0;
}