summaryrefslogtreecommitdiff
path: root/pjnath
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-10-26 03:59:34 +0000
committerBenny Prijono <bennylp@teluu.com>2007-10-26 03:59:34 +0000
commit72ce2f4f3d03984f41ac7f1abfa2353276fbc0fe (patch)
treed32b62b6c7b82e11b20cb7e443f7b82cbaefaadc /pjnath
parent103e4fbf619f5d4a8289a641d86925710fb74308 (diff)
More ticket #399: fixed bug that triggers assertion in the timer
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1523 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath')
-rw-r--r--pjnath/src/pjnath/nat_detect.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/pjnath/src/pjnath/nat_detect.c b/pjnath/src/pjnath/nat_detect.c
index aa0615b9..9fd669cc 100644
--- a/pjnath/src/pjnath/nat_detect.c
+++ b/pjnath/src/pjnath/nat_detect.c
@@ -78,6 +78,7 @@ typedef struct nat_detect_session
pj_timer_heap_t *timer_heap;
pj_timer_entry timer;
+ unsigned timer_executed;
void *user_data;
pj_stun_nat_detect_cb *cb;
@@ -358,6 +359,11 @@ static void end_session(nat_detect_session *sess,
char errmsg[PJ_ERR_MSG_SIZE];
pj_time_val delay;
+ if (sess->timer.id != 0) {
+ pj_timer_heap_cancel(sess->timer_heap, &sess->timer);
+ sess->timer.id = 0;
+ }
+
pj_bzero(&result, sizeof(result));
errmsg[0] = '\0';
result.status_text = errmsg;
@@ -830,26 +836,26 @@ static void on_sess_timer(pj_timer_heap_t *th,
} else if (te->id == TIMER_TEST) {
- int executed;
pj_bool_t next_timer;
pj_mutex_lock(sess->mutex);
- executed = test_executed(sess);
next_timer = PJ_FALSE;
- if (executed == ST_TEST_1) {
+ if (sess->timer_executed == 0) {
send_test(sess, ST_TEST_1, NULL, 0);
next_timer = PJ_TRUE;
- } else if (executed == ST_TEST_2) {
+ } else if (sess->timer_executed == 1) {
send_test(sess, ST_TEST_2, NULL, CHANGE_IP_PORT_FLAG);
next_timer = PJ_TRUE;
- } else if (executed == ST_TEST_3) {
+ } else if (sess->timer_executed == 2) {
send_test(sess, ST_TEST_3, NULL, CHANGE_PORT_FLAG);
} else {
pj_assert(!"Shouldn't have timer at this state");
}
+ ++sess->timer_executed;
+
if (next_timer) {
pj_time_val delay = {0, TEST_INTERVAL};
pj_timer_heap_schedule(th, te, &delay);