Skip to content

Commit

Permalink
fix order of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hajoha committed May 15, 2024
1 parent 93c60bf commit c6aa2db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions src/iperf_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,33 @@
*/

#include <signal.h>
#include <string.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);
}

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__)
2 changes: 1 addition & 1 deletion src/iperf_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c6aa2db

Please sign in to comment.