diff --git a/src/iperf_pthread.c b/src/iperf_pthread.c index ea4918bcd..9eb0fd445 100644 --- a/src/iperf_pthread.c +++ b/src/iperf_pthread.c @@ -7,34 +7,33 @@ */ #include +#include #include "iperf_pthread.h" int pthread_setcanceltype(int type, int *oldtype) { return 0; } int pthread_setcancelstate(int state, int *oldstate) { return 0; } -int pthread_cancel(pthread_t thread_id) { - int status; - if ((status = iperf_set_thread_exit_handler()) == 0) { - status = pthread_kill(thread_id, SIGUSR1); - } - return status; -} - void iperf_thread_exit_handler(int sig) -{ +{ pthread_exit(0); } - int iperf_set_thread_exit_handler() { int rc; struct sigaction actions; - memset(&actions, 0, sizeof(actions)); + memset(&actions, 0, sizeof(actions)); sigemptyset(&actions.sa_mask); - actions.sa_flags = 0; + actions.sa_flags = 0; actions.sa_handler = iperf_thread_exit_handler; rc = sigaction(SIGUSR1, &actions, NULL); return rc; } +int pthread_cancel(pthread_t thread_id) { + int status; + if ((status = iperf_set_thread_exit_handler()) == 0) { + status = pthread_kill(thread_id, SIGUSR1); + } + return status; +} #endif // defined(HAVE_PTHREAD) && defined(__ANDROID__) diff --git a/src/iperf_pthread.h b/src/iperf_pthread.h index 44828d6a9..468fb21e6 100644 --- a/src/iperf_pthread.h +++ b/src/iperf_pthread.h @@ -10,7 +10,7 @@ */ #define PTHREAD_CANCEL_ASYNCHRONOUS 0 -#define PTHREAD_CANCEL_ENABLE NULL +#define PTHREAD_CANCEL_ENABLE 0 int pthread_setcanceltype(int type, int *oldtype); int pthread_setcancelstate(int state, int *oldstate);