[asterisk-commits] tilghman: branch 1.2 r60846 - /branches/1.2/channels/chan_local.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Apr 8 19:37:19 MST 2007


Author: tilghman
Date: Sun Apr  8 21:37:18 2007
New Revision: 60846

URL: http://svn.digium.com/view/asterisk?view=rev&rev=60846
Log:
Bug 9505 - If the return value for local_queue_frame is set, then p->lock is no longer valid.

Modified:
    branches/1.2/channels/chan_local.c

Modified: branches/1.2/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_local.c?view=diff&rev=60846&r1=60845&r2=60846
==============================================================================
--- branches/1.2/channels/chan_local.c (original)
+++ branches/1.2/channels/chan_local.c Sun Apr  8 21:37:18 2007
@@ -179,7 +179,8 @@
 		res = local_queue_frame(p, isoutbound, &answer, ast);
 	} else
 		ast_log(LOG_WARNING, "Huh?  Local is being asked to answer?\n");
-	ast_mutex_unlock(&p->lock);
+	if (!res)
+		ast_mutex_unlock(&p->lock);
 	return res;
 }
 
@@ -262,7 +263,8 @@
 		ast_log(LOG_DEBUG, "Not posting to queue since already masked on '%s'\n", ast->name);
 		res = 0;
 	}
-	ast_mutex_unlock(&p->lock);
+	if (!res)
+		ast_mutex_unlock(&p->lock);
 	return res;
 }
 
@@ -302,8 +304,8 @@
 	ast_mutex_lock(&p->lock);
 	isoutbound = IS_OUTBOUND(ast, p);
 	f.subclass = condition;
-	res = local_queue_frame(p, isoutbound, &f, ast);
-	ast_mutex_unlock(&p->lock);
+	if (!(res = local_queue_frame(p, isoutbound, &f, ast)))
+		ast_mutex_unlock(&p->lock);
 	return res;
 }
 
@@ -320,8 +322,8 @@
 	ast_mutex_lock(&p->lock);
 	isoutbound = IS_OUTBOUND(ast, p);
 	f.subclass = digit;
-	res = local_queue_frame(p, isoutbound, &f, ast);
-	ast_mutex_unlock(&p->lock);
+	if (!(res = local_queue_frame(p, isoutbound, &f, ast)))
+		ast_mutex_unlock(&p->lock);
 	return res;
 }
 
@@ -340,8 +342,8 @@
 	f.subclass = subclass;
 	f.data = (char *)data;
 	f.datalen = datalen;
-	res = local_queue_frame(p, isoutbound, &f, ast);
-	ast_mutex_unlock(&p->lock);
+	if (!(res = local_queue_frame(p, isoutbound, &f, ast)))
+		ast_mutex_unlock(&p->lock);
 	return res;
 }
 
@@ -430,7 +432,7 @@
 	struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
 	struct local_pvt *cur, *prev=NULL;
 	struct ast_channel *ochan = NULL;
-	int glaredetect;
+	int glaredetect, res = 0;
 
 	if (!p)
 		return -1;
@@ -485,8 +487,9 @@
 		/* Need to actually hangup since there is no PBX */
 		ochan = p->chan;
 	else
-		local_queue_frame(p, isoutbound, &f, NULL);
-	ast_mutex_unlock(&p->lock);
+		res = local_queue_frame(p, isoutbound, &f, NULL);
+	if (!res)
+		ast_mutex_unlock(&p->lock);
 	if (ochan)
 		ast_hangup(ochan);
 	return 0;



More information about the asterisk-commits mailing list