]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix race in agent/masquerade
authorMark Spencer <markster@digium.com>
Wed, 16 Jul 2003 18:54:16 +0000 (18:54 +0000)
committerMark Spencer <markster@digium.com>
Wed, 16 Jul 2003 18:54:16 +0000 (18:54 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1196 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channel.c
channels/chan_agent.c

index 4eddb9c9f730d515a7667f47c2b80c4cc9d3e1f8..bcbf8f11adfd166f157cb514334757e45fa5a2da 100755 (executable)
--- a/channel.c
+++ b/channel.c
@@ -1811,6 +1811,7 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
           not really safe not to XXX */
        ast_queue_frame(original, &null, 0);
        ast_queue_frame(clone, &null, 0);
+       ast_log(LOG_DEBUG, "Done planning to masquerade %s into the structure of %s\n", original->name, clone->name);
        return 0;
 }
 
index 77a8ba10e3a18689260f8312ff0d99cd88ab26af..cf6e3b362fdc0469efcb9838a967910b8f85dea0 100755 (executable)
@@ -634,8 +634,10 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
                                ast_setstate(chan, AST_STATE_UP);
                                /* Go ahead and mark the channel as a zombie so that masquerade will
                                   destroy it for us, and we need not call ast_hangup */
+                               ast_pthread_mutex_lock(&parent->lock);
                                chan->zombie = 1;
                                ast_channel_masquerade(parent, chan);
+                               ast_pthread_mutex_unlock(&parent->lock);
                                p->abouttograb = 0;
                        } else {
                                ast_log(LOG_DEBUG, "Sneaky, parent disappeared in the mean time...\n");