summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2012-04-26 09:24:50 +0000
committerBenny Prijono <bennylp@teluu.com>2012-04-26 09:24:50 +0000
commitdb0d51acdd840ecbcca2667e6d9c62777290683f (patch)
treed57ef5b2f5bb6b8d44ad5aa6313eba76862d3b59 /pjsip
parentfa3a819e8ba210d7897dfb1925b688632750cfe9 (diff)
Indirectly related to re #1465: acquire transport reference when invoking transport send(), to prevent transport from being destroyed accidently while sending is in progress, and also to reset the idle timer
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/1.x@4092 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsip/sip_transport.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
index 556868cf..2f3ceeba 100644
--- a/pjsip/src/pjsip/sip_transport.c
+++ b/pjsip/src/pjsip/sip_transport.c
@@ -659,6 +659,11 @@ PJ_DEF(pj_status_t) pjsip_transport_send( pjsip_transport *tr,
return PJSIP_EPENDINGTX;
}
+ /* Add reference to prevent deletion, and to cancel idle timer if
+ * it's running.
+ */
+ pjsip_transport_add_ref(tr);
+
/* Fill in tp_info. */
tdata->tp_info.transport = tr;
pj_memcpy(&tdata->tp_info.dst_addr, addr, addr_len);
@@ -676,8 +681,10 @@ PJ_DEF(pj_status_t) pjsip_transport_send( pjsip_transport *tr,
*/
if (tr->tpmgr->on_tx_msg) {
status = (*tr->tpmgr->on_tx_msg)(tr->endpt, tdata);
- if (status != PJ_SUCCESS)
+ if (status != PJ_SUCCESS) {
+ pjsip_transport_dec_ref(tr);
return status;
+ }
}
/* Save callback data. */
@@ -699,6 +706,7 @@ PJ_DEF(pj_status_t) pjsip_transport_send( pjsip_transport *tr,
pjsip_tx_data_dec_ref(tdata);
}
+ pjsip_transport_dec_ref(tr);
return status;
}