From 78ce50707aff32caa195be402721001d51dba2c0 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 11 Apr 2012 09:41:25 +0000 Subject: More re #1481: Destroying the regc may lead to dangling binding in the register, so instead of destroying the regc, instruct it to release the transport instead git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@4037 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip-ua/sip_reg.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'pjsip/src/pjsip-ua') diff --git a/pjsip/src/pjsip-ua/sip_reg.c b/pjsip/src/pjsip-ua/sip_reg.c index 750e22f7..c02c17bb 100644 --- a/pjsip/src/pjsip-ua/sip_reg.c +++ b/pjsip/src/pjsip-ua/sip_reg.c @@ -440,6 +440,17 @@ PJ_DEF(pj_status_t) pjsip_regc_set_transport( pjsip_regc *regc, return PJ_SUCCESS; } +/* Release transport */ +PJ_DEF(pj_status_t) pjsip_regc_release_transport(pjsip_regc *regc) +{ + PJ_ASSERT_RETURN(regc, PJ_EINVAL); + if (regc->last_transport) { + pjsip_transport_dec_ref(regc->last_transport); + regc->last_transport = NULL; + } + return PJ_SUCCESS; +} + PJ_DEF(pj_status_t) pjsip_regc_add_headers( pjsip_regc *regc, const pjsip_hdr *hdr_list) @@ -1269,7 +1280,9 @@ PJ_DEF(pj_status_t) pjsip_regc_send(pjsip_regc *regc, pjsip_tx_data *tdata) pj_lock_acquire(regc->lock); /* Get last transport used and add reference to it */ - if (tdata->tp_info.transport != regc->last_transport) { + if (tdata->tp_info.transport != regc->last_transport && + status==PJ_SUCCESS) + { if (regc->last_transport) { pjsip_transport_dec_ref(regc->last_transport); regc->last_transport = NULL; -- cgit v1.2.3