aboutsummaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/bionic/pthread_accessor.h16
-rw-r--r--libc/bionic/pthread_kill.cpp6
2 files changed, 13 insertions, 9 deletions
diff --git a/libc/bionic/pthread_accessor.h b/libc/bionic/pthread_accessor.h
index eb8c35090..2a320f6df 100644
--- a/libc/bionic/pthread_accessor.h
+++ b/libc/bionic/pthread_accessor.h
@@ -36,6 +36,14 @@ class pthread_accessor {
Unlock();
}
+ void Unlock() {
+ if (is_locked_) {
+ is_locked_ = false;
+ thread_ = NULL;
+ pthread_mutex_unlock(&gThreadListLock);
+ }
+ }
+
pthread_internal_t& operator*() const { return *thread_; }
pthread_internal_t* operator->() const { return thread_; }
pthread_internal_t* get() const { return thread_; }
@@ -49,14 +57,6 @@ class pthread_accessor {
is_locked_ = true;
}
- void Unlock() {
- if (is_locked_) {
- is_locked_ = false;
- thread_ = NULL;
- pthread_mutex_unlock(&gThreadListLock);
- }
- }
-
// Disallow copy and assignment.
pthread_accessor(const pthread_accessor&);
void operator=(const pthread_accessor&);
diff --git a/libc/bionic/pthread_kill.cpp b/libc/bionic/pthread_kill.cpp
index 2d37ae9fb..54f71ee52 100644
--- a/libc/bionic/pthread_kill.cpp
+++ b/libc/bionic/pthread_kill.cpp
@@ -42,7 +42,11 @@ int pthread_kill(pthread_t t, int sig) {
return ESRCH;
}
- int rc = tgkill(getpid(), thread->tid, sig);
+ // 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;
}