diff options
author | Benny Prijono <bennylp@teluu.com> | 2013-03-21 11:38:05 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2013-03-21 11:38:05 +0000 |
commit | e815e81926d7319d412210764ac8e74c1c71b676 (patch) | |
tree | 0b6c5c46b81305d53dd77051d9c42e04021ea0a1 | |
parent | 5b146fdf156b646e2aa77e7563b5e77c337cf0c3 (diff) |
More on re #1646: added flag to prevent another transmit data from being transmitted while we are waiting for the previous one to be flushed from transport queue
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4448 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjsip/src/pjsip/sip_transaction.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c index d1846605..f2e558a5 100644 --- a/pjsip/src/pjsip/sip_transaction.c +++ b/pjsip/src/pjsip/sip_transaction.c @@ -1920,12 +1920,21 @@ static void transport_callback(void *token, pjsip_tx_data *tdata, { pjsip_transaction *tsx = (pjsip_transaction*) token; + /* In other circumstances, locking tsx->grp_lock AFTER transport mutex + * will introduce deadlock if another thread is currently sending a + * SIP message to the transport. But this should be safe as there should + * be no way this callback could be called while another thread is + * sending a message. + */ + pj_grp_lock_acquire(tsx->grp_lock); + tsx->transport_flag &= ~(TSX_HAS_PENDING_TRANSPORT); + pj_grp_lock_release(tsx->grp_lock); + if (sent < 0) { pj_time_val delay = {0, 0}; char errmsg[PJ_ERR_MSG_SIZE]; - pj_str_t err; - err = pj_strerror(-sent, errmsg, sizeof(errmsg)); + pj_strerror(-sent, errmsg, sizeof(errmsg)); PJ_LOG(2,(tsx->obj_name, "Transport failed to send %s! Err=%d (%s)", pjsip_tx_data_get_info(tdata), -sent, errmsg)); @@ -2001,6 +2010,7 @@ static pj_status_t tsx_send_msg( pjsip_transaction *tsx, * https://trac.pjsip.org/repos/ticket/1646 */ pj_grp_lock_add_ref(tsx->grp_lock); + tsx->transport_flag |= TSX_HAS_PENDING_TRANSPORT; status = pjsip_transport_send( tsx->transport, tdata, &tsx->addr, tsx->addr_len, tsx, @@ -2009,6 +2019,7 @@ static pj_status_t tsx_send_msg( pjsip_transaction *tsx, status = PJ_SUCCESS; else { /* Operation completes immediately */ + tsx->transport_flag &= ~(TSX_HAS_PENDING_TRANSPORT); pj_grp_lock_dec_ref(tsx->grp_lock); } |