Fix potential race in check_availability
authorMark Spencer <markster@digium.com>
Wed, 16 Jul 2003 02:25:53 +0000 (02:25 +0000)
committerMark Spencer <markster@digium.com>
Wed, 16 Jul 2003 02:25:53 +0000 (02:25 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1191 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_agent.c

index 5031a35..77a8ba1 100755 (executable)
@@ -605,7 +605,7 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
                        continue;
                }
                ast_pthread_mutex_lock(&p->lock);
-               if (p->pending && ((p->group && (newlyavailable->group & p->group)) || !strcmp(p->agent, newlyavailable->agent))) {
+               if (!p->abouttograb && p->pending && ((p->group && (newlyavailable->group & p->group)) || !strcmp(p->agent, newlyavailable->agent))) {
                        ast_log(LOG_DEBUG, "Call '%s' looks like a winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
                        /* We found a pending call, time to merge */
                        chan = agent_new(newlyavailable, AST_STATE_DOWN);