[asterisk-commits] bweschke: trunk r43307 - in /trunk: ./ channels/chan_agent.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Sep 19 20:51:02 MST 2006


Author: bweschke
Date: Tue Sep 19 22:51:01 2006
New Revision: 43307

URL: http://svn.digium.com/view/asterisk?rev=43307&view=rev
Log:
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. 


........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_agent.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Modified: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?rev=43307&r1=43306&r2=43307&view=diff
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Tue Sep 19 22:51:01 2006
@@ -815,7 +815,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;
 }
@@ -955,7 +956,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, &ast_null_frame);
 			ast_mutex_unlock(&p->lock);	/* For other thread to read the condition. */
@@ -971,7 +972,20 @@
 			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 @@
 			ast_log( LOG_ERROR, "A blocker exists after agent channel ownership acquired\n" );
 			CRASH;
 		}
-		ast_indicate(p->chan, AST_CONTROL_UNHOLD);
 	}
 	return tmp;
 }



More information about the asterisk-commits mailing list