[master] 092287f Keep track of needing to join the thread
Poul-Henning Kamp
phk at FreeBSD.org
Thu Jan 19 13:56:05 CET 2017
commit 092287f6919a338bdc0ebaf2e12e7107c8bb449f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Jan 19 12:29:10 2017 +0000
Keep track of needing to join the thread
diff --git a/bin/varnishtest/vtc_barrier.c b/bin/varnishtest/vtc_barrier.c
index 04f1d71..8eb0348 100644
--- a/bin/varnishtest/vtc_barrier.c
+++ b/bin/varnishtest/vtc_barrier.c
@@ -64,6 +64,7 @@ struct barrier {
/* fields below are only for BARRIER_SOCK */
pthread_t thread;
volatile unsigned active;
+ volatile unsigned need_join;
};
static pthread_mutex_t barrier_mtx;
@@ -236,6 +237,7 @@ barrier_sock(struct barrier *b, const char *av, struct vtclog *vl)
barrier_expect(b, av, vl);
b->type = BARRIER_SOCK;
b->active = 1;
+ b->need_join = 1;
/* NB. We can use the BARRIER_COND's pthread_cond_t to wait until the
* socket is ready for convenience.
@@ -419,8 +421,11 @@ cmd_barrier(CMD_ARGS)
case BARRIER_COND:
break;
case BARRIER_SOCK:
- b->active = 0;
- AZ(pthread_join(b->thread, NULL));
+ if (b->need_join) {
+ b->active = 0;
+ AZ(pthread_join(b->thread, NULL));
+ b->need_join = 0;
+ }
break;
default:
WRONG("Wrong barrier type");
More information about the varnish-commit
mailing list