diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-28 20:34:43 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-08-28 20:34:43 +0200 |
commit | 659c49ab31ac9f29adaf29b2eac4e8841ce5404e (patch) | |
tree | ed6701a478b362bb002329ee4242bf00c9a8a79c /src | |
parent | docker: add initial configuration (diff) | |
download | cimple-659c49ab31ac9f29adaf29b2eac4e8841ce5404e.tar.gz cimple-659c49ab31ac9f29adaf29b2eac4e8841ce5404e.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/server.c | 2 |
1 files changed, 1 insertions, 1 deletions
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; |