aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/signal_cond.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsan/signal_cond.cc')
-rw-r--r--test/tsan/signal_cond.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/test/tsan/signal_cond.cc b/test/tsan/signal_cond.cc
index f5eae745d407..beb2e0266e50 100644
--- a/test/tsan/signal_cond.cc
+++ b/test/tsan/signal_cond.cc
@@ -6,17 +6,16 @@
#include <semaphore.h>
// Test that signals can be delivered to blocked pthread_cond_wait.
-// https://code.google.com/p/thread-sanitizer/issues/detail?id=91
+// https://github.com/google/sanitizers/issues/498
int g_thread_run = 1;
pthread_mutex_t mutex;
pthread_cond_t cond;
-sem_t sem;
void sig_handler(int sig) {
(void)sig;
write(1, "SIGNAL\n", sizeof("SIGNAL\n") - 1);
- sem_post(&sem);
+ barrier_wait(&barrier);
}
void* my_thread(void* arg) {
@@ -28,7 +27,11 @@ void* my_thread(void* arg) {
}
int main() {
- sem_init(&sem, 0, 0);
+ barrier_init(&barrier, 2);
+
+ pthread_mutex_init(&mutex, 0);
+ pthread_cond_init(&cond, 0);
+
signal(SIGUSR1, &sig_handler);
pthread_t thr;
pthread_create(&thr, 0, &my_thread, 0);
@@ -36,8 +39,7 @@ int main() {
// (can't use barrier_wait for that)
sleep(1);
pthread_kill(thr, SIGUSR1);
- while (sem_wait(&sem) == -1 && errno == EINTR) {
- }
+ barrier_wait(&barrier);
pthread_mutex_lock(&mutex);
g_thread_run = 0;
pthread_cond_signal(&cond);