summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-10-16 20:05:27 +0000
committerBenny Prijono <bennylp@teluu.com>2006-10-16 20:05:27 +0000
commit58a72d24ec0f82142fd7b7378b11b3e189fc00ea (patch)
tree484d7676401608883a9f179d28b5ad6f42c2444e /pjsip
parent79770ffce0f1240f4230a5bb96c0bb937ec21991 (diff)
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
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsip-ua/sip_reg.c15
1 files changed, 13 insertions, 2 deletions
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;
}