From: Mark Spencer Date: Tue, 8 Jul 2003 18:50:02 +0000 (+0000) Subject: Don't retry lock if there is no channel X-Git-Tag: 0.5.0~329 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a5a9db828e0dcae7b72339f175bf91b48603a05e;p=thirdparty%2Fasterisk.git Don't retry lock if there is no channel git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1167 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_agent.c b/channels/chan_agent.c index 0e90ac39bf..29dc13a5ad 100755 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -438,10 +438,12 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state) p->app_sleep_cond = 0; if( pthread_mutex_trylock(&p->app_lock) ) { - ast_queue_frame(p->chan, &null_frame, 1); - ast_pthread_mutex_unlock(&p->lock); /* For other thread to read the condition. */ - ast_pthread_mutex_lock(&p->app_lock); - ast_pthread_mutex_lock(&p->lock); + if (p->chan) { + ast_queue_frame(p->chan, &null_frame, 1); + ast_pthread_mutex_unlock(&p->lock); /* For other thread to read the condition. */ + ast_pthread_mutex_lock(&p->app_lock); + ast_pthread_mutex_lock(&p->lock); + } if( !p->chan ) { ast_log(LOG_WARNING, "Agent disconnected while we were connecting the call\n");