diff options
author | Benny Prijono <bennylp@teluu.com> | 2010-01-27 09:09:27 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2010-01-27 09:09:27 +0000 |
commit | 67983fb24f15e72df308c0e52f7055f38c09615c (patch) | |
tree | 690ab787b99e0ae17ff38c62f654d6af919d7229 | |
parent | 55f5a20f1f0385175e5d6b82695b78fbd738a2b3 (diff) |
Fixed ticket #1036: Stray timer may be registered by SIP TCP and TLS transport in destroy routine, which could crash the program on Symbian (thanks Tamàs Solymosi for the report)
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3077 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjsip/include/pjsip/sip_transport.h | 1 | ||||
-rw-r--r-- | pjsip/src/pjsip/sip_transport.c | 8 |
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. */ |