tsan: deflake test

llvm-svn: 202484
This commit is contained in:
Dmitry Vyukov 2014-02-28 10:47:07 +00:00
parent cdb9fafa71
commit 371639ea1f
1 changed files with 3 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
struct Ctx {
pthread_mutex_t m;
@ -31,6 +32,8 @@ int main() {
while (!c->done)
pthread_cond_wait(&c->c, &c->m);
pthread_mutex_unlock(&c->m);
// w/o this sleep, it can be reported as use-after-free
sleep(1);
delete c;
pthread_join(th, 0);
}