[asterisk-commits] jpeeler: branch jpeeler/bug12269 r149800 - /team/jpeeler/bug12269/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 15 15:39:44 CDT 2008


Author: jpeeler
Date: Wed Oct 15 15:39:43 2008
New Revision: 149800

URL: http://svn.digium.com/view/asterisk?view=rev&rev=149800
Log:
Make this branch actually work.

Modified:
    team/jpeeler/bug12269/channels/chan_agent.c

Modified: team/jpeeler/bug12269/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/bug12269/channels/chan_agent.c?view=diff&rev=149800&r1=149799&r2=149800
==============================================================================
--- team/jpeeler/bug12269/channels/chan_agent.c (original)
+++ team/jpeeler/bug12269/channels/chan_agent.c Wed Oct 15 15:39:43 2008
@@ -671,7 +671,7 @@
 {
 	struct agent_pvt *p = ast->tech_pvt;
 	int res = -1;
-ast_log(LOG_NOTICE, "jpeeler: called on %s but really indicating on %s\n", ast->name, p->chan->name);
+//ast_log(LOG_NOTICE, "jpeeler: called on %s but really indicating on %s\n", ast->name, p->chan->name);
 	ast_mutex_lock(&p->lock);
 	if (p->chan && !ast_check_hangup(p->chan))
 		res = p->chan->tech->indicate ? p->chan->tech->indicate(p->chan, condition, data, datalen) : -1;
@@ -1087,6 +1087,12 @@
 	p->app_sleep_cond = 0;
 	ast_mutex_lock(&p->app_lock);
 	p->app_lock_flag = 1;
+/* jpeeler: optimization?
+	if (ast_test_flag(p->chan, AST_FLAG_BLOCKING)) {
+		ast_log(LOG_NOTICE, "jpeeler: Blocker detected\n");
+		pthread_kill(p->chan->blocker, SIGURG);
+	}
+*/
 	ast_mutex_unlock(&p->app_lock);
 	if(ast_strlen_zero(p->loginchan) && !p->app_lock_flag) {
 		if (p->chan) {
@@ -1125,11 +1131,9 @@
 	if (p->chan)
 		ast_indicate(p->chan, AST_CONTROL_UNHOLD);
 	/* After the above step, there should not be any blockers. */
-	if (p->chan) {
-		if (ast_test_flag(p->chan, AST_FLAG_BLOCKING)) {
-			ast_log( LOG_ERROR, "A blocker exists after agent channel ownership acquired\n" );
-			ast_assert(ast_test_flag(p->chan, AST_FLAG_BLOCKING) == 0);
-		}
+	if (p->chan && ast_test_flag(p->chan, AST_FLAG_BLOCKING) && p->app_lock_flag == 0) {
+		ast_log(LOG_ERROR, "A blocker (%p) exists on %s after agent channel ownership acquired\n",(void *) p->chan->blocker, p->chan->name);
+		ast_assert(ast_test_flag(p->chan, AST_FLAG_BLOCKING) == 0);
 	}
 	return tmp;
 }
@@ -2271,21 +2275,21 @@
 							ast_mutex_unlock(&p->lock);
 							AST_LIST_UNLOCK(&agents);
 							/*	Synchronize channel ownership between call to agent and itself. */
-ast_log(LOG_NOTICE, "jpeeler: waiting for app_lock\n");
+//ast_log(LOG_NOTICE, "jpeeler: waiting for app_lock (app_lock_flag=%d)\n", p->app_lock_flag);
 							ast_mutex_lock(&p->app_lock);
+//ast_log(LOG_NOTICE, "jpeeler: app_lock obtained by thread %p\n", (void *) pthread_self());
 							if (p->app_lock_flag == 1) {
+								p->app_lock_flag = 0;
 								ast_cond_wait(&p->app_complete_cond, &p->app_lock);
 							}
-ast_log(LOG_NOTICE, "jpeeler: app_lock obtained by thread %p\n", (void *) pthread_self());
+							ast_mutex_unlock(&p->app_lock);
+//ast_log(LOG_NOTICE, "jpeeler: app_lock released by thread %p\n", (void *) pthread_self());
 							ast_mutex_lock(&p->lock);
 							ast_mutex_unlock(&p->lock);
 							if (p->ackcall > 1) 
 								res = agent_ack_sleep(p);
 							else
 								res = ast_safe_sleep_conditional( chan, 1000, agent_cont_sleep, p );
-							p->app_lock_flag = 0;
-							ast_mutex_unlock( &p->app_lock );
-ast_log(LOG_NOTICE, "jpeeler: app_lock released by thread %p\n", (void *) pthread_self());
 							if ((p->ackcall > 1)  && (res == 1)) {
 								AST_LIST_LOCK(&agents);
 								ast_mutex_lock(&p->lock);




More information about the asterisk-commits mailing list