a713e06b9634890c6019e377e0ae3fa52bdef2a8
[openwrt/openwrt.git] / package / network / utils / iperf / patches / 0001-fix-latent-bug-in-signal-handling-per-POSIX-calling-.patch
1 From 7c0ac64ebea38d0d9ff4d160db4d33bc087a3490 Mon Sep 17 00:00:00 2001
2 From: Robert McMahon <rjmcmahon@rjmcmahon.com>
3 Date: Mon, 16 Jul 2018 17:51:29 -0700
4 Subject: [PATCH] fix latent bug in signal handling, per POSIX calling exit()
5 in signal handler is not safe. Use _exit() instead. Also, detect the user
6 signal SIGINT for the case of server needing two invocations to stop server
7 threads. Note: the server threads still need some work from graceful
8 termination with a single ctrl-c
9
10 ---
11
12 --- a/compat/signal.c
13 +++ b/compat/signal.c
14 @@ -171,7 +171,7 @@ void sig_exit( int inSigno ) {
15 static int num = 0;
16 if ( num++ == 0 ) {
17 fflush( 0 );
18 - exit( 0 );
19 + _exit(0);
20 }
21 } /* end sig_exit */
22
23 --- a/src/main.cpp
24 +++ b/src/main.cpp
25 @@ -268,7 +268,7 @@ void Sig_Interupt( int inSigno ) {
26 // We try to not allow a single interrupt handled by multiple threads
27 // to completely kill the app so we save off the first thread ID
28 // then that is the only thread that can supply the next interrupt
29 - if ( thread_equalid( sThread, thread_zeroid() ) ) {
30 + if ( (inSigno == SIGINT) && thread_equalid( sThread, thread_zeroid() ) ) {
31 sThread = thread_getid();
32 } else if ( thread_equalid( sThread, thread_getid() ) ) {
33 sig_exit( inSigno );
34 @@ -420,9 +420,3 @@ VOID ServiceStop() {
35 }
36
37 #endif
38 -
39 -
40 -
41 -
42 -
43 -