aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbweschke <bweschke@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-20 03:51:01 +0000
committerbweschke <bweschke@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-20 03:51:01 +0000
commit40a6ddcf9441cec7ac54b0e6455754aa418dd4ec (patch)
treed94e1d9512e347538a0c5e42cd4ee1ce4091bde5
parent349f2660ae6ea37a57c5e76e59a3063c4d6ca75f (diff)
Merged revisions 42133 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r42133 | bweschke | 2006-09-06 14:16:41 -0400 (Wed, 06 Sep 2006) | 6 lines 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/trunk@43307 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_agent.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index d5c327965..7ab6f61b0 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -815,7 +815,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;
}
@@ -955,7 +956,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, &ast_null_frame);
ast_mutex_unlock(&p->lock); /* For other thread to read the condition. */
@@ -971,7 +972,20 @@ 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, &ast_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;
+ }
}
+ ast_indicate(p->chan, AST_CONTROL_UNHOLD);
p->owning_app = pthread_self();
/* After the above step, there should not be any blockers. */
if (p->chan) {
@@ -979,7 +993,6 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state)
ast_log( LOG_ERROR, "A blocker exists after agent channel ownership acquired\n" );
CRASH;
}
- ast_indicate(p->chan, AST_CONTROL_UNHOLD);
}
return tmp;
}