Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv10620/channels

Modified Files:
        chan_local.c 
Log Message:
Perform some extra checks before performing masquerades


Index: chan_local.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_local.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- chan_local.c        14 Sep 2005 20:46:49 -0000      1.53
+++ chan_local.c        19 Oct 2005 03:45:49 -0000      1.54
@@ -183,26 +183,36 @@
 {
        if (p->alreadymasqed || p->nooptimization)
                return;
-       if (isoutbound && p->chan && p->chan->_bridge /* Not 
ast_bridged_channel!  Only go one step! */ && p->owner && !p->owner->readq) {
+       if (!p->chan || !p->owner)
+               return;
+       if (isoutbound&& p->chan->_bridge /* Not ast_bridged_channel!  Only go 
one step! */ && !p->owner->readq) {
                /* Masquerade bridged channel into owner */
                /* Lock everything we need, one by one, and give up if
                   we can't get everything.  Remember, we'll get another
                   chance in just a little bit */
                if (!ast_mutex_trylock(&(p->chan->_bridge)->lock)) {
-                       if (!ast_mutex_trylock(&p->owner->lock)) {
-                               ast_channel_masquerade(p->owner, 
p->chan->_bridge);
-                               p->alreadymasqed = 1;
-                               ast_mutex_unlock(&p->owner->lock);
+                       if (!p->chan->_bridge->_softhangup) {
+                               if (!ast_mutex_trylock(&p->owner->lock)) {
+                                       if (!p->owner->_softhangup) {
+                                               
ast_channel_masquerade(p->owner, p->chan->_bridge);
+                                               p->alreadymasqed = 1;
+                                       }
+                                       ast_mutex_unlock(&p->owner->lock);
+                               }
+                               ast_mutex_unlock(&(p->chan->_bridge)->lock);
                        }
-                       ast_mutex_unlock(&(p->chan->_bridge)->lock);
                }
        } else if (!isoutbound && p->owner && p->owner->_bridge && p->chan && 
!p->chan->readq) {
                /* Masquerade bridged channel into chan */
                if (!ast_mutex_trylock(&(p->owner->_bridge)->lock)) {
-                       if (!ast_mutex_trylock(&p->chan->lock)) {
-                               ast_channel_masquerade(p->chan, 
p->owner->_bridge);
-                               p->alreadymasqed = 1;
-                               ast_mutex_unlock(&p->chan->lock);
+                       if (!p->owner->_bridge->_softhangup) {
+                               if (!ast_mutex_trylock(&p->chan->lock)) {
+                                       if (!p->chan->_softhangup) {
+                                               ast_channel_masquerade(p->chan, 
p->owner->_bridge);
+                                               p->alreadymasqed = 1;
+                                       }
+                                       ast_mutex_unlock(&p->chan->lock);
+                               }
                        }
                        ast_mutex_unlock(&(p->owner->_bridge)->lock);
                }

_______________________________________________
Asterisk-Cvs mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-cvs

Reply via email to