diff options
author | Paul Cadach <paul@odt.east.telecom.kz> | 2006-09-23 18:28:23 +0000 |
---|---|---|
committer | Paul Cadach <paul@odt.east.telecom.kz> | 2006-09-23 18:28:23 +0000 |
commit | 56fb349222232ed56ac71c94792cf44ff92dda5a (patch) | |
tree | 38b74006712acea1eb185118a13d52a9cca98cd6 /channels/chan_h323.c | |
parent | 1d50a8e881326f278e13502bf64566eb1d242641 (diff) |
Avoid possible deadlock on channel destruction
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@43540 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_h323.c')
-rw-r--r-- | channels/chan_h323.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/channels/chan_h323.c b/channels/chan_h323.c index f167c0781..38fb22c40 100644 --- a/channels/chan_h323.c +++ b/channels/chan_h323.c @@ -2433,34 +2433,36 @@ static void *do_monitor(void *data) h323_do_reload(); } /* Check for interfaces needing to be killed */ - ast_mutex_lock(&iflock); + if (!ast_mutex_trylock(&iflock)) { #if 1 - do { - for (oh323 = iflist; oh323; oh323 = oh323->next) { + do { + for (oh323 = iflist; oh323; oh323 = oh323->next) { + if (!ast_mutex_trylock(&oh323->lock)) { + if (oh323->needdestroy) { + __oh323_destroy(oh323); + break; + } + ast_mutex_unlock(&oh323->lock); + } + } + } while (/*oh323*/ 0); +#else +restartsearch: + oh323 = iflist; + while(oh323) { if (!ast_mutex_trylock(&oh323->lock)) { if (oh323->needdestroy) { __oh323_destroy(oh323); - break; + goto restartsearch; } ast_mutex_unlock(&oh323->lock); + oh323 = oh323->next; } } - } while (/*oh323*/ 0); -#else -restartsearch: - oh323 = iflist; - while(oh323) { - if (!ast_mutex_trylock(&oh323->lock)) { - if (oh323->needdestroy) { - __oh323_destroy(oh323); - goto restartsearch; - } - ast_mutex_unlock(&oh323->lock); - oh323 = oh323->next; - } - } #endif - ast_mutex_unlock(&iflock); + ast_mutex_unlock(&iflock); + } else + oh323 = (struct oh323_pvt *)1; /* Force fast loop */ pthread_testcancel(); /* Wait for sched or io */ res = ast_sched_wait(sched); |