[asterisk-commits] pcadach: trunk r43540 -
/trunk/channels/chan_h323.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sat Sep 23 11:28:24 MST 2006
Author: pcadach
Date: Sat Sep 23 13:28:23 2006
New Revision: 43540
URL: http://svn.digium.com/view/asterisk?rev=43540&view=rev
Log:
Avoid possible deadlock on channel destruction
Modified:
trunk/channels/chan_h323.c
Modified: trunk/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_h323.c?rev=43540&r1=43539&r2=43540&view=diff
==============================================================================
--- trunk/channels/chan_h323.c (original)
+++ trunk/channels/chan_h323.c Sat Sep 23 13:28:23 2006
@@ -2433,34 +2433,36 @@
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);
More information about the asterisk-commits
mailing list