File tree Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -475,6 +475,7 @@ enum {
475
475
IEPTHREADJOIN = 152 , // Unable to join thread (check perror)
476
476
IEPTHREADATTRINIT = 153 , // Unable to initialize thread attribute (check perror)
477
477
IEPTHREADATTRDESTROY = 154 , // Unable to destroy thread attribute (check perror)
478
+ IEPTHREADSIGMASK = 155 , // Unable to initialize sub thread signal mask (check perror)
478
479
/* Stream errors */
479
480
IECREATESTREAM = 200 , // Unable to create a new stream (check herror/perror)
480
481
IEINITSTREAM = 201 , // Unable to initialize stream (check herror/perror)
Original file line number Diff line number Diff line change 36
36
#include <sys/select.h>
37
37
#include <sys/uio.h>
38
38
#include <arpa/inet.h>
39
+ #include <signal.h>
39
40
40
41
#include "iperf.h"
41
42
#include "iperf_api.h"
@@ -56,6 +57,23 @@ iperf_client_worker_run(void *s) {
56
57
struct iperf_stream * sp = (struct iperf_stream * ) s ;
57
58
struct iperf_test * test = sp -> test ;
58
59
60
+ /* Blocking signal to make sure that signal will be handled by main thread */
61
+ sigset_t set ;
62
+ sigemptyset (& set );
63
+ #ifdef SIGTERM
64
+ sigaddset (& set , SIGTERM );
65
+ #endif
66
+ #ifdef SIGHUP
67
+ sigaddset (& set , SIGHUP );
68
+ #endif
69
+ #ifdef SIGINT
70
+ sigaddset (& set , SIGINT );
71
+ #endif
72
+ if (pthread_sigmask (SIG_BLOCK , & set , NULL ) != 0 ) {
73
+ i_errno = IEPTHREADSIGMASK ;
74
+ goto cleanup_and_fail ;
75
+ }
76
+
59
77
/* Allow this thread to be cancelled even if it's in a syscall */
60
78
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS , NULL );
61
79
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE , NULL );
Original file line number Diff line number Diff line change @@ -505,6 +505,9 @@ iperf_strerror(int int_errno)
505
505
snprintf (errstr , len , "unable to create thread attributes" );
506
506
perr = 1 ;
507
507
break ;
508
+ case IEPTHREADSIGMASK :
509
+ snprintf (errstr , len , "unable to change mask of blocked signals" );
510
+ break ;
508
511
case IEPTHREADATTRDESTROY :
509
512
snprintf (errstr , len , "unable to destroy thread attributes" );
510
513
perr = 1 ;
Original file line number Diff line number Diff line change 45
45
#include <sys/resource.h>
46
46
#include <sched.h>
47
47
#include <setjmp.h>
48
+ #include <signal.h>
48
49
49
50
#include "iperf.h"
50
51
#include "iperf_api.h"
@@ -69,6 +70,23 @@ iperf_server_worker_run(void *s) {
69
70
struct iperf_stream * sp = (struct iperf_stream * ) s ;
70
71
struct iperf_test * test = sp -> test ;
71
72
73
+ /* Blocking signal to make sure that signal will be handled by main thread */
74
+ sigset_t set ;
75
+ sigemptyset (& set );
76
+ #ifdef SIGTERM
77
+ sigaddset (& set , SIGTERM );
78
+ #endif
79
+ #ifdef SIGHUP
80
+ sigaddset (& set , SIGHUP );
81
+ #endif
82
+ #ifdef SIGINT
83
+ sigaddset (& set , SIGINT );
84
+ #endif
85
+ if (pthread_sigmask (SIG_BLOCK , & set , NULL ) != 0 ) {
86
+ i_errno = IEPTHREADSIGMASK ;
87
+ goto cleanup_and_fail ;
88
+ }
89
+
72
90
/* Allow this thread to be cancelled even if it's in a syscall */
73
91
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS , NULL );
74
92
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE , NULL );
You can’t perform that action at this time.
0 commit comments