summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pjsip/include/pjsip/sip_transport.h1
-rw-r--r--pjsip/src/pjsip/sip_transport.c8
2 files changed, 7 insertions, 2 deletions
diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h
index 04c5255c..6592fc98 100644
--- a/pjsip/include/pjsip/sip_transport.h
+++ b/pjsip/include/pjsip/sip_transport.h
@@ -709,6 +709,7 @@ struct pjsip_transport
pj_lock_t *lock; /**< Lock object. */
pj_bool_t tracing; /**< Tracing enabled? */
pj_bool_t is_shutdown; /**< Being shutdown? */
+ pj_bool_t is_destroying; /**< Destroy in progress? */
/** Key for indexing this transport in hash table. */
pjsip_transport_key key;
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
index b6e79183..f5d7ee57 100644
--- a/pjsip/src/pjsip/sip_transport.c
+++ b/pjsip/src/pjsip/sip_transport.c
@@ -816,8 +816,10 @@ PJ_DEF(pj_status_t) pjsip_transport_dec_ref( pjsip_transport *tp )
if (pj_atomic_dec_and_get(tp->ref_cnt) == 0) {
pj_lock_acquire(tp->tpmgr->lock);
- /* Verify again. */
- if (pj_atomic_get(tp->ref_cnt) == 0) {
+ /* Verify again. Do not register timer if the transport is
+ * being destroyed.
+ */
+ if (pj_atomic_get(tp->ref_cnt) == 0 && !tp->is_destroying) {
pj_time_val delay;
/* If transport is in graceful shutdown, then this is the
@@ -898,6 +900,8 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,
pj_lock_acquire(tp->lock);
pj_lock_acquire(mgr->lock);
+ tp->is_destroying = PJ_TRUE;
+
/*
* Unregister timer, if any.
*/