diff --git a/src/iperf_client_api.c b/src/iperf_client_api.c index 37d741f87..98c32b9e4 100644 --- a/src/iperf_client_api.c +++ b/src/iperf_client_api.c @@ -75,7 +75,7 @@ iperf_client_worker_run(void *s) { } /* Allow this thread to be cancelled even if it's in a syscall */ - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); while (! (test->done) && ! (sp->done)) { diff --git a/src/iperf_pthread.h b/src/iperf_pthread.h index 9fe3db8a2..021ad3890 100644 --- a/src/iperf_pthread.h +++ b/src/iperf_pthread.h @@ -9,8 +9,20 @@ /* Adding missing `pthread` related definitions in Android. */ -#define PTHREAD_CANCEL_ASYNCHRONOUS 0 -#define PTHREAD_CANCEL_ENABLE 0 + enum + { + PTHREAD_CANCEL_ENABLE, + #define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE + PTHREAD_CANCEL_DISABLE + #define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE + }; + enum + { + PTHREAD_CANCEL_DEFERRED, + #define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED + PTHREAD_CANCEL_ASYNCHRONOUS + #define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS + }; int pthread_setcanceltype(int type, int *oldtype); int pthread_setcancelstate(int state, int *oldstate); diff --git a/src/iperf_server_api.c b/src/iperf_server_api.c index 8e9b41623..43124e067 100644 --- a/src/iperf_server_api.c +++ b/src/iperf_server_api.c @@ -88,7 +88,7 @@ iperf_server_worker_run(void *s) { } /* Allow this thread to be cancelled even if it's in a syscall */ - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); while (! (test->done) && ! (sp->done)) {