From d044ad6c5b4221648c555da16196804e4721299c Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Wed, 25 Oct 2023 11:00:59 +0700 Subject: [PATCH] Fix possible race condition in NAT detect between timer and socket. (#3747) Change-Id: I8647a23dc2adb6a859c18f1795e7d2b8524ff06b --- pjnath/src/pjnath/nat_detect.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pjnath/src/pjnath/nat_detect.c b/pjnath/src/pjnath/nat_detect.c index 47e4ce005..5d1353d49 100644 --- a/pjnath/src/pjnath/nat_detect.c +++ b/pjnath/src/pjnath/nat_detect.c @@ -412,8 +412,8 @@ static void end_session(nat_detect_session *sess, delay.sec = 0; delay.msec = 0; - sess->timer.id = TIMER_DESTROY; - pj_timer_heap_schedule(sess->timer_heap, &sess->timer, &delay); + pj_timer_heap_schedule_w_grp_lock(sess->timer_heap, &sess->timer, &delay, + TIMER_DESTROY, sess->grp_lock); } @@ -933,7 +933,8 @@ static void on_sess_timer(pj_timer_heap_t *th, if (next_timer) { pj_time_val delay = {0, TEST_INTERVAL}; - pj_timer_heap_schedule(th, te, &delay); + pj_timer_heap_schedule_w_grp_lock(th, te, &delay, + TIMER_TEST, sess->grp_lock); } else { te->id = 0; }