]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
automerge commit
authorAutomerge script <automerge@asterisk.org>
Wed, 6 Sep 2006 19:02:18 +0000 (19:02 +0000)
committerAutomerge script <automerge@asterisk.org>
Wed, 6 Sep 2006 19:02:18 +0000 (19:02 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@42147 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_agent.c

index 65a8fbef48d2b529279a69796064b782d86ceaec..bba17969c57c77e0dd6975816a6d30ccae9d7032 100644 (file)
@@ -828,7 +828,8 @@ static int agent_hangup(struct ast_channel *ast)
                        ast_mutex_unlock(&p->lock);
                }
                /* Release ownership of the agent to other threads (presumably running the login app). */
-               ast_mutex_unlock(&p->app_lock);
+               if (ast_strlen_zero(p->loginchan))
+                       ast_mutex_unlock(&p->app_lock);
        }
        return 0;
 }
@@ -972,7 +973,7 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
                 * implemented in the kernel for this.
                 */
                p->app_sleep_cond = 0;
-               if( ast_mutex_trylock(&p->app_lock) )
+               if( ast_strlen_zero(p->loginchan) && ast_mutex_trylock(&p->app_lock) )
                {
                        if (p->chan) {
                                ast_queue_frame(p->chan, &null_frame);
@@ -991,6 +992,18 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
                                ast_mutex_unlock(&p->app_lock);
                                return NULL;
                        }
+               } else if (!ast_strlen_zero(p->loginchan)) {
+                       if (p->chan)
+                               ast_queue_frame(p->chan, &null_frame);
+                       if (!p->chan) {
+                               ast_log(LOG_WARNING, "Agent disconnected while we were connecting the call\n");
+                               p->owner = NULL;
+                               tmp->tech_pvt = NULL;
+                               p->app_sleep_cond = 1;
+                               ast_channel_free( tmp );
+                               ast_mutex_unlock(&p->lock);     /* For other thread to read the condition. */
+                                return NULL;
+                       }       
                }
                p->owning_app = pthread_self();
                /* After the above step, there should not be any blockers. */