[Asterisk-cvs] asterisk/channels chan_agent.c,1.104,1.105
markster at lists.digium.com
markster at lists.digium.com
Sat Jan 15 17:27:49 CST 2005
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv5109/channels
Modified Files:
chan_agent.c
Log Message:
Fix agent deadlock (bug #3311)
Index: chan_agent.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_agent.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- chan_agent.c 15 Jan 2005 21:51:37 -0000 1.104
+++ chan_agent.c 15 Jan 2005 23:31:19 -0000 1.105
@@ -480,18 +480,21 @@
{
struct agent_pvt *p = ast->pvt->pvt;
int res = -1;
+ int newstate=0;
ast_mutex_lock(&p->lock);
p->acknowledged = 0;
if (!p->chan) {
if (p->pending) {
ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
- ast_setstate(ast, AST_STATE_DIALING);
+ newstate = AST_STATE_DIALING;
res = 0;
} else {
ast_log(LOG_NOTICE, "Whoa, they hung up between alloc and call... what are the odds of that?\n");
res = -1;
}
ast_mutex_unlock(&p->lock);
+ if (newstate)
+ ast_setstate(ast, newstate);
return res;
} else if (!ast_strlen_zero(p->loginchan)) {
time(&p->start);
@@ -543,9 +546,9 @@
{
/* Call is immediately up, or might need ack */
if (p->ackcall > 1)
- ast_setstate(ast, AST_STATE_RINGING);
+ newstate = AST_STATE_RINGING;
else {
- ast_setstate(ast, AST_STATE_UP);
+ newstate = AST_STATE_UP;
if (recordagentcalls)
agent_start_monitoring(ast,0);
p->acknowledged = 1;
@@ -554,6 +557,8 @@
}
CLEANUP(ast,p);
ast_mutex_unlock(&p->lock);
+ if (newstate)
+ ast_setstate(ast, newstate);
return res;
}
@@ -797,6 +802,7 @@
else
snprintf(tmp->name, sizeof(tmp->name), "Agent/%s", p->agent);
tmp->type = channeltype;
+ /* Safe, agentlock already held */
ast_setstate(tmp, state);
tmp->pvt->pvt = p;
tmp->pvt->send_digit = agent_digit;
@@ -1037,6 +1043,7 @@
/* Note -- parent may have disappeared */
if (p->abouttograb) {
newlyavailable->acknowledged = 1;
+ /* Safe -- agent lock already held */
ast_setstate(parent, AST_STATE_UP);
ast_setstate(chan, AST_STATE_UP);
strncpy(parent->context, chan->context, sizeof(parent->context) - 1);
More information about the svn-commits
mailing list