From 039235b3a3ab67a03b163a1e08ae65b3e63080b6 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Tue, 9 Jun 2015 21:46:37 +0800 Subject: [PATCH] lock before set quit flag --- skynet-src/skynet_start.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skynet-src/skynet_start.c b/skynet-src/skynet_start.c index 1d9ae6c4..4123c624 100644 --- a/skynet-src/skynet_start.c +++ b/skynet-src/skynet_start.c @@ -112,9 +112,10 @@ thread_timer(void *p) { // wakeup socket thread skynet_socket_exit(); // wakeup all worker thread - // we don't need lock m before set m->quit, because it can only set once. + pthread_mutex_lock(&m->mutex); m->quit = 1; pthread_cond_broadcast(&m->cond); + pthread_mutex_unlock(&m->mutex); return NULL; }