From 659c49ab31ac9f29adaf29b2eac4e8841ce5404e Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 28 Aug 2022 20:34:43 +0200 Subject: server: notify all threads about shutting down The problem is pthread_cond_destroy is unsafe to call if there're threads waiting in pthread_cond_wait. I'm not sure this fix is enough: what if the "broadcast" doesn't reach the threads until we call pthread_cond_destroy? Does it even work that way? Idk --- src/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server.c b/src/server.c index c2941c5..f5318fa 100644 --- a/src/server.c +++ b/src/server.c @@ -313,7 +313,7 @@ static int server_set_stopping(struct server *server) server->stopping = 1; - ret = pthread_cond_signal(&server->server_cv); + ret = pthread_cond_broadcast(&server->server_cv); if (ret) { pthread_print_errno(ret, "pthread_cond_signal"); goto unlock; -- cgit v1.2.3