diff options
Diffstat (limited to 'src/tools/cbr')
-rw-r--r-- | src/tools/cbr/cbr.c | 6 | ||||
-rw-r--r-- | src/tools/cbr/cbr_server.c | 22 |
2 files changed, 11 insertions, 17 deletions
diff --git a/src/tools/cbr/cbr.c b/src/tools/cbr/cbr.c index 0cce50db..65783119 100644 --- a/src/tools/cbr/cbr.c +++ b/src/tools/cbr/cbr.c @@ -75,8 +75,10 @@ int main(int argc, char ** argv) bool server = false; - /* FIXME: should be argv[0] */ - ap_init(argv[0]); + if (ap_init(argv[0]) < 0) { + printf("Failed to init.\n"); + exit(EXIT_FAILURE); + } server_settings.interval = 1; /* One second reporting interval */ server_settings.timeout = 1; 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; } |