From 58a72d24ec0f82142fd7b7378b11b3e189fc00ea Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Mon, 16 Oct 2006 20:05:27 +0000 Subject: Fixed bug in client registration when pjsip_endpt_send_request() returns immediate error git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@776 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip-ua/sip_reg.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsip-ua/sip_reg.c b/pjsip/src/pjsip-ua/sip_reg.c index cfb59d4f..b7770488 100644 --- a/pjsip/src/pjsip-ua/sip_reg.c +++ b/pjsip/src/pjsip-ua/sip_reg.c @@ -581,6 +581,10 @@ static void tsx_callback(void *token, pjsip_event *event) event->body.tsx_state.src.rdata : NULL; } + /* Increment pending_tsx temporarily to prevent regc from + * being destroyed. + */ + ++regc->pending_tsx; /* Call callback. */ if (expiration == 0xFFFF) expiration = -1; @@ -590,6 +594,8 @@ static void tsx_callback(void *token, pjsip_event *event) rdata, expiration, contact_cnt, contact); + /* Decrement pending_tsx */ + --regc->pending_tsx; } /* Delete the record if user destroy regc during the callback. */ @@ -623,12 +629,17 @@ PJ_DEF(pj_status_t) pjsip_regc_send(pjsip_regc *regc, pjsip_tx_data *tdata) /* Increment pending transaction first, since transaction callback * may be called even before send_request() returns! */ - ++regc->pending_tsx; + regc->pending_tsx += 2; status = pjsip_endpt_send_request(regc->endpt, tdata, -1, regc, &tsx_callback); if (status!=PJ_SUCCESS) { - --regc->pending_tsx; PJ_LOG(4,(THIS_FILE, "Error sending request, status=%d", status)); } + --regc->pending_tsx; + + /* Delete the record if user destroy regc during the callback. */ + if (regc->_delete_flag && regc->pending_tsx==0) { + pjsip_regc_destroy(regc); + } return status; } -- cgit v1.2.3