[asterisk-commits] tilghman: trunk r272145 - /trunk/channels/chan_mgcp.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 23 13:25:58 CDT 2010


Author: tilghman
Date: Wed Jun 23 13:25:54 2010
New Revision: 272145

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=272145
Log:
Load all lines from realtime, not just the first one.

(closes issue #17144)
 Reported by: nahuelgreco
 Patches: 
       20100513__issue17144__trunk.diff.txt uploaded by tilghman (license 14)
 Tested by: tilghman

Modified:
    trunk/channels/chan_mgcp.c

Modified: trunk/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_mgcp.c?view=diff&rev=272145&r1=272144&r2=272145
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Wed Jun 23 13:25:54 2010
@@ -1654,7 +1654,6 @@
 	struct mgcp_endpoint *e;
 	char *c = NULL, *line;
 	char lines[256];
-	char tmp[4096];
 	int i, j;
 
 	ast_debug(1, "*** find Realtime MGCPGW\n");
@@ -1672,6 +1671,19 @@
 		return NULL;
 	}
 
+	/*!
+	 * \note This is a fairly odd way of instantiating lines.  Instead of each
+	 * line created by virtue of being in the database (and loaded via
+	 * ast_load_realtime_multientry), this code forces a specific order with a
+	 * "lines" entry in the "mgcpgw" record.  This has benefits, because as with
+	 * chan_dahdi, values are inherited across definitions.  The downside is
+	 * that it's not as clear what the values will be simply by looking at a
+	 * single row in the database, and it's probable that the sanest configuration
+	 * should have the first column in the "mgcpep" table be "clearvars", with a
+	 * static value of "all", if any variables are set at all.  It may be worth
+	 * making this assumption explicit in the code in the future, and then just
+	 * using ast_load_realtime_multientry for the "mgcpep" records.
+	 */
 	lines[0] = '\0';
 	for (gwv = mgcpgwconfig; gwv; gwv = gwv->next) {
 		if (!strcasecmp(gwv->name, "lines")) {
@@ -1679,33 +1691,30 @@
 			break;
 		}
 	}
+	/* Position gwv at the end of the list */
 	for (gwv = gwv && gwv->next ? gwv : mgcpgwconfig; gwv->next; gwv = gwv->next);
+
 	if (!ast_strlen_zero(lines)) {
-		for (c = lines, line = tmp; *c; c++) {
-			*line = *c;
-			if (*c == ',') {
-					*(line) = 0;
-					mgcpepconfig = ast_load_realtime("mgcpep", "name", at, "line", tmp, NULL);
-					gwv->next = mgcpepconfig;
-
-					while (gwv->next) {
-						if (!strcasecmp(gwv->next->name, "line")) {
-							epname = gwv->next;
-							gwv->next = gwv->next->next;
-						} else {
-							gwv = gwv->next;
-						}
-					}
-						/* moving the line var to the end */
-					if (epname) {
-						gwv->next = epname;
-						epname->next = NULL;
-						gwv = gwv->next;
-					}
-					mgcpepconfig = NULL;
-					line = tmp;
-			} else {
-				line++;
+		AST_DECLARE_APP_ARGS(args,
+			AST_APP_ARG(line)[100];
+		);
+		AST_STANDARD_APP_ARGS(args, lines);
+		for (i = 0; i < args.argc; i++) {
+			gwv->next = ast_load_realtime("mgcpep", "name", at, "line", args.line[i], NULL);
+
+			/* Remove "line" AND position gwv at the end of the list. */
+			for (epname = NULL; gwv->next; gwv = gwv->next) {
+				if (!strcasecmp(gwv->next->name, "line")) {
+					/* Remove it from the list */
+					epname = gwv->next;
+					gwv->next = gwv->next->next;
+				}
+			}
+			/* Since "line" instantiates the configuration, we have to move it to the end. */
+			if (epname) {
+				gwv->next = epname;
+				epname->next = NULL;
+				gwv = gwv->next;
 			}
 		}
 	}




More information about the asterisk-commits mailing list