summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-04 20:51:09 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-04 20:54:19 +0200
commit432e93affce4d5ddcc816f826268bc68d5789756 (patch)
treee911e77bb63015bbaee6e81dd12da6a6377d4157
parent502d7b1585edb0ee89cac178f20af8bfdbf5cc64 (diff)
downloadouroboros-432e93affce4d5ddcc816f826268bc68d5789756.tar.gz
ouroboros-432e93affce4d5ddcc816f826268bc68d5789756.zip
tools: cbr: Fix server cleanup
The server should cleanup whenever the listen thread exits.
-rw-r--r--src/tools/cbr/cbr_server.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/tools/cbr/cbr_server.c b/src/tools/cbr/cbr_server.c
index 1890c842..fc23363f 100644
--- a/src/tools/cbr/cbr_server.c
+++ b/src/tools/cbr/cbr_server.c
@@ -47,18 +47,11 @@ pthread_cond_t fds_signal;
void shutdown_server(int signo, siginfo_t * info, void * c)
{
- int i;
-
switch(signo) {
case SIGINT:
case SIGTERM:
case SIGHUP:
pthread_cancel(listen_thread);
-
- for (i = 0; i < THREADS_SIZE; i++) {
- pthread_cancel(threads[i]);
- }
-
default:
return;
}
@@ -226,19 +219,18 @@ int server_main()
exit(EXIT_FAILURE);
}
- for (i = 0; i < THREADS_SIZE; i++) {
- pthread_create(&threads[i], NULL,
- worker, NULL);
- }
+ for (i = 0; i < THREADS_SIZE; i++)
+ pthread_create(&threads[i], NULL, worker, NULL);
- pthread_create(&listen_thread, NULL,
- listener, NULL);
+ pthread_create(&listen_thread, NULL, listener, NULL);
pthread_join(listen_thread, NULL);
- for (i = 0; i < THREADS_SIZE; i++) {
+ for (i = 0; i < THREADS_SIZE; i++)
+ pthread_cancel(threads[i]);
+
+ for (i = 0; i < THREADS_SIZE; i++)
pthread_join(threads[i], NULL);
- }
return 0;
}