[Asterisk-cvs] asterisk pbx.c,1.181,1.182

anthm at lists.digium.com anthm at lists.digium.com
Wed Dec 8 13:26:27 CST 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv3453

Modified Files:
	pbx.c 
Log Message:
fix bug 2994 (off by 1 error)

Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.181
retrieving revision 1.182
diff -u -d -r1.181 -r1.182
--- pbx.c	7 Dec 2004 20:38:43 -0000	1.181
+++ pbx.c	8 Dec 2004 18:24:04 -0000	1.182
@@ -3837,8 +3837,8 @@
 			strncpy(chan->context, context, sizeof(chan->context) - 1);
 		if (exten && !ast_strlen_zero(exten))
 			strncpy(chan->exten, exten, sizeof(chan->context) - 1);
-		if (priority)
-			chan->priority = priority;	
+		if(priority > -1)
+			chan->priority = priority;
 		return 0;
 	}
 	return -1;
@@ -3869,7 +3869,7 @@
 			ast_explicit_goto(tmpchan,
 							  (context && !ast_strlen_zero(context)) ? context : chan->context,
 							  (exten && !ast_strlen_zero(exten)) ? exten : chan->exten,
-							  priority ? priority : chan->priority);
+							  priority - 1);
 
 			/* Masquerade into temp channel */
 			ast_channel_masquerade(tmpchan, chan);
@@ -5420,18 +5420,28 @@
 
 static int __ast_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority, int async) 
 {
-	int (*goto_func)(struct ast_channel *chan, const char *context, const char *exten, int priority) = async ? ast_async_goto : ast_explicit_goto;
+	int (*goto_func)(struct ast_channel *chan, const char *context, const char *exten, int priority) = NULL;
 
 	if(chan) {
-		if(ast_exists_extension(chan, 
-								context ? context : chan->context,
-								exten ? exten : chan->exten,
-								priority ? priority : chan->priority,
-								chan->cid.cid_num)) {
+
+		if (async) {
+			goto_func = ast_async_goto;
+		} else { 
+			goto_func = ast_explicit_goto;
+			priority--;
+			if(priority < 0)
+				priority = 0;
+		}
+
+		if (ast_exists_extension(chan, 
+								 context ? context : chan->context,
+								 exten ? exten : chan->exten,
+								 priority,
+								 chan->cid.cid_num)) {
 			return goto_func(chan,
-								  context ? context : chan->context,
-								  exten ? exten : chan->exten,
-								  (priority ? priority : chan->priority) - 1);
+							 context ? context : chan->context,
+							 exten ? exten : chan->exten,
+							 priority);
 		} else 
 			return -3;
 	}
@@ -5501,12 +5511,7 @@
 		ipri = chan->priority + (ipri * mode);
 
 	/* This channel is currently in the PBX */
-	if (context && !ast_strlen_zero(context))
-		strncpy(chan->context, context, sizeof(chan->context) - 1);
-	if (exten && !ast_strlen_zero(exten))
-		strncpy(chan->exten, exten, sizeof(chan->context) - 1);
-	chan->priority = ipri - 1;
-
+	ast_explicit_goto(chan, context, exten, ipri - 1);
 	ast_cdr_update(chan);
 	return 0;
 




More information about the svn-commits mailing list