[asterisk-commits] bweschke: branch 1.2 r42133 -
/branches/1.2/channels/chan_agent.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Sep 6 11:16:42 MST 2006
Author: bweschke
Date: Wed Sep 6 13:16:41 2006
New Revision: 42133
URL: http://svn.digium.com/view/asterisk?rev=42133&view=rev
Log:
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.
Modified:
branches/1.2/channels/chan_agent.c
Modified: branches/1.2/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_agent.c?rev=42133&r1=42132&r2=42133&view=diff
==============================================================================
--- branches/1.2/channels/chan_agent.c (original)
+++ branches/1.2/channels/chan_agent.c Wed Sep 6 13:16:41 2006
@@ -828,7 +828,8 @@
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 @@
* 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 @@
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. */
More information about the asterisk-commits
mailing list