0
0
mirror of https://github.com/termux/termux-packages.git synced 2024-12-12 13:03:31 +00:00
termux-packages/packages/iperf3/pthread_cancel.patch
2024-05-11 20:57:08 +03:00

61 lines
1.7 KiB
Diff

diff --git a/src/iperf_pthread.c b/src/iperf_pthread.c
index ea4918bcd..55ddd530f 100644
--- a/src/iperf_pthread.c
+++ b/src/iperf_pthread.c
@@ -6,19 +6,10 @@
* as Android NDK does not support `pthread_cancel()`.
*/
+#include <string.h>
#include <signal.h>
#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);
@@ -37,4 +28,14 @@ int iperf_set_thread_exit_handler() {
return rc;
}
+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;
+}
+
#endif // defined(HAVE_PTHREAD) && defined(__ANDROID__)
diff --git a/src/iperf_pthread.h b/src/iperf_pthread.h
index 44828d6a9..9fe3db8a2 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);
@@ -18,4 +18,4 @@ int pthread_cancel(pthread_t thread_id);
#endif // defined(__ANDROID__)
-#endif // defined(HAVE_PTHREAD)
\ No newline at end of file
+#endif // defined(HAVE_PTHREAD)