Skip to content

Commit 91729c7

Browse files
vjardinVincent Jardin
authored and
Vincent Jardin
committed
fix PPPOE SIGTERM
The daemon does not quit in case of a SIGTERM when a PPPoE session is established but there is no PPPOE signaling traffic. We can notice that it keeps blocking on recvmmsg() syscall: [pid 262269] recvmmsg(46, <unfinished ...> [pid 262268] recvmmsg(44, <unfinished ...> [pid 262264] recvmmsg(43, <unfinished ...> Those fd are: gtp-guard 262250 root 43u pack 4610713 0t0 PPP_SES type=SOCK_RAW gtp-guard 262250 root 44u pack 4641817 0t0 PPP_DIS type=SOCK_RAW gtp-guard 262250 root 46u pack 4629533 0t0 PPP_SES type=SOCK_RAW
1 parent d76fbe7 commit 91729c7

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)