summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/opentracker.c b/opentracker.c
index f579b92..e0f16d7 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -49,7 +49,9 @@ static void panic(const char *routine) {
49 exit(111); 49 exit(111);
50} 50}
51 51
52/* Say we are stopping, wake the loop, and let main do the work on its own stack. */ 52/* Say we are stopping, wake the loop, and let main do the work on its own
53 stack. Everything other than SIGINT falls through and does nothing, which
54 is what OT_SIGNAL_WAKE wants: returning from the read is all it is for. */
53static void signal_handler(int s) { 55static void signal_handler(int s) {
54 if (s == SIGINT) { 56 if (s == SIGINT) {
55 const char byte = 0; 57 const char byte = 0;
@@ -85,7 +87,8 @@ static void install_signal_handlers(void) {
85 sa.sa_handler = signal_handler; 87 sa.sa_handler = signal_handler;
86 sigemptyset(&sa.sa_mask); 88 sigemptyset(&sa.sa_mask);
87 sa.sa_flags = 0; 89 sa.sa_flags = 0;
88 if ((sigaction(SIGINT, &sa, NULL) == -1) || (sigaction(SIGALRM, &sa, NULL) == -1)) 90 if ((sigaction(SIGINT, &sa, NULL) == -1) || (sigaction(SIGALRM, &sa, NULL) == -1) ||
91 (sigaction(OT_SIGNAL_WAKE, &sa, NULL) == -1))
89 panic("install_signal_handlers"); 92 panic("install_signal_handlers");
90 93
91 sigaddset(&signal_mask, SIGINT); 94 sigaddset(&signal_mask, SIGINT);
@@ -397,7 +400,6 @@ static void listen_start_udp_workers(void) {
397 if (entry->proto != FLAG_UDP || entry->workers <= 0) 400 if (entry->proto != FLAG_UDP || entry->workers <= 0)
398 continue; 401 continue;
399 402
400 socket_set_blocking((int)entry->sock, 1);
401 event_del((int)entry->sock); 403 event_del((int)entry->sock);
402 udp_worker_install(entry->sock); 404 udp_worker_install(entry->sock);
403 405
@@ -409,8 +411,7 @@ static void listen_start_udp_workers(void) {
409 if (sock == -1) { 411 if (sock == -1) {
410 fprintf(stderr, "Warning: could not bind another socket for udp worker %d: %s. Sharing the first instead.\n", worker, strerror(errno)); 412 fprintf(stderr, "Warning: could not bind another socket for udp worker %d: %s. Sharing the first instead.\n", worker, strerror(errno));
411 sock = entry->sock; 413 sock = entry->sock;
412 } else 414 }
413 socket_set_blocking((int)sock, 1);
414 } 415 }
415 udp_worker_install(sock); 416 udp_worker_install(sock);
416 } 417 }
@@ -548,9 +549,10 @@ int main(int argc, char **argv) {
548 listen_start_udp_workers(); 549 listen_start_udp_workers();
549 550
550 server_mainloop(0); 551 server_mainloop(0);
552 udp_workers_deinit();
551 553
552 /* The loop has left, so no thread is serving any more and the teardown 554 /* No thread is serving any more, so the teardown can run where a debugger
553 can run where a debugger and the sanitizers can follow it */ 555 and the sanitizers can follow it */
554 trackerlogic_deinit(); 556 trackerlogic_deinit();
555#ifdef WANT_SYSLOGS 557#ifdef WANT_SYSLOGS
556 closelog(); 558 closelog();