Be sure we have the agent lock
authorMark Spencer <markster@digium.com>
Sat, 6 Sep 2003 19:10:08 +0000 (19:10 +0000)
committerMark Spencer <markster@digium.com>
Sat, 6 Sep 2003 19:10:08 +0000 (19:10 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1478 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_agent.c

index 2f3b4cb..cbdff7a 100755 (executable)
@@ -1213,6 +1213,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                                if (res)
                                                                        break;
 
+                                                               ast_mutex_lock(&agentlock);
                                                                ast_mutex_lock(&p->lock);
                                                                if (p->lastdisc.tv_sec) {
                                                                        gettimeofday(&tv, NULL);
@@ -1227,6 +1228,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                                        }
                                                                }
                                                                ast_mutex_unlock(&p->lock);
+                                                               ast_mutex_unlock(&agentlock);
                                                                /*      Synchronize channel ownership between call to agent and itself. */
                                                                ast_mutex_lock( &p->app_lock );
                                                                ast_mutex_lock(&p->lock);
@@ -1239,9 +1241,11 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                                                                        agent_cont_sleep, p );
                                                                ast_mutex_unlock( &p->app_lock );
                                                                if ((p->ackcall > 1)  && (res == 1)) {
+                                                                       ast_mutex_lock(&agentlock);
                                                                        ast_mutex_lock(&p->lock);
                                                                        check_availability(p, 0);
                                                                        ast_mutex_unlock(&p->lock);
+                                                                       ast_mutex_unlock(&agentlock);
                                                                        res = 0;
                                                                }
                                                                sched_yield();