aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorbweschke <bweschke@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-06 18:16:41 +0000
committerbweschke <bweschke@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-06 18:16:41 +0000
commit42ccece77f93550e92982c58cc5ce12644a8abb4 (patch)
tree72997fc96190df02775f64be453b6d100e5f7c90 /channels
parent47e7ce9010259b247568fcd1fdeb5d31fe6d4a08 (diff)
Look ma! No more deadlocks! <sic>
As posted from #7458 and others similar to it in Mantis: p->app_lock was a mutex really designed for use with agents not in callback mode. That being the case, I've tried to code it so that when callback mode is used, the app_lock mutex will not be locked/unlocked at all. Please let me know how you make out - and if you continue to deadlock now, please reproduce the deadlock logging information and post to Mantis. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@42133 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_agent.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 65a8fbef4..bba17969c 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -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. */