Skip to content

Commit 39f2617

Browse files
authored
Merge pull request #35 from vjardin/vj_fixsigterm
fix PPPOE SIGTERM
2 parents d76fbe7 + 91729c7 commit 39f2617

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/gtp_pppoe.c

+7
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ gtp_pppoe_worker_task(void *arg)
353353
}
354354

355355
signal_noignore_sig(SIGUSR1);
356+
357+
/* Set Cancellation before a blocking syscall such as recvmmsg() */
358+
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
359+
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
360+
356361
log_message(LOG_INFO, "%s(): Starting PPPoE Worker %s"
357362
, __FUNCTION__, pname);
358363

@@ -419,6 +424,8 @@ gtp_pppoe_worker_release(gtp_pppoe_worker_t *w)
419424
return;
420425

421426
pthread_kill(w->task, SIGUSR1);
427+
sched_yield(); /* yield to handle the SIGUSR1 */
428+
pthread_cancel(w->task); /* stop all the blocking syscalls, recvmmsg() */
422429
pthread_join(w->task, NULL);
423430
mpkt_destroy(&w->mpkt);
424431
pkt_queue_destroy(&w->pkt_q);

0 commit comments

Comments
 (0)