[asterisk-commits] tilghman: trunk r87263 - in /trunk: ./ funcs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Oct 28 09:11:01 CDT 2007


Author: tilghman
Date: Sun Oct 28 09:11:01 2007
New Revision: 87263

URL: http://svn.digium.com/view/asterisk?view=rev&rev=87263
Log:
Merged revisions 87262 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r87262 | tilghman | 2007-10-28 08:46:55 -0500 (Sun, 28 Oct 2007) | 7 lines

Add autoservice to several more functions which might delay in their responses.
Also, make sure that func_odbc functions have a channel on which to set
variables.
Reported by russell
Fixed by tilghman
Closes issue #11099

........

Modified:
    trunk/   (props changed)
    trunk/funcs/func_cut.c
    trunk/funcs/func_odbc.c
    trunk/funcs/func_realtime.c
    trunk/funcs/func_strings.c

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

Modified: trunk/funcs/func_cut.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_cut.c?view=diff&rev=87263&r1=87262&r2=87263
==============================================================================
--- trunk/funcs/func_cut.c (original)
+++ trunk/funcs/func_cut.c Sun Oct 28 09:11:01 2007
@@ -126,7 +126,7 @@
 	);
 
 	memset(buffer, 0, buflen); 
-	
+
 	parse = ast_strdupa(data);
 
 	AST_STANDARD_APP_ARGS(args, parse);
@@ -235,6 +235,9 @@
 {
 	int ret = -1;
 
+	if (chan)
+		ast_autoservice_start(chan);
+
 	switch (cut_internal(chan, data, buf, len)) {
 	case ERROR_NOARG:
 		ast_log(LOG_ERROR, "Syntax: CUT(<varname>,<char-delim>,<range-spec>) - missing argument!\n");
@@ -251,6 +254,9 @@
 	default:
 		ast_log(LOG_ERROR, "Unknown internal error\n");
 	}
+
+	if (chan)
+		ast_autoservice_stop(chan);
 
 	return ret;
 }

Modified: trunk/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_odbc.c?view=diff&rev=87263&r1=87262&r2=87263
==============================================================================
--- trunk/funcs/func_odbc.c (original)
+++ trunk/funcs/func_odbc.c Sun Oct 28 09:11:01 2007
@@ -139,7 +139,7 @@
 	struct odbc_obj *obj = NULL;
 	struct acf_odbc_query *query;
 	char *t, buf[2048]="", varname[15];
-	int i, dsn;
+	int i, dsn, bogus_chan = 0;
 	AST_DECLARE_APP_ARGS(values,
 		AST_APP_ARG(field)[100];
 	);
@@ -162,12 +162,24 @@
 		return -1;
 	}
 
+	if (!chan) {
+		if ((chan = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/func_odbc")))
+			bogus_chan = 1;
+	}
+
+	if (chan)
+		ast_autoservice_start(chan);
+
 	/* Parse our arguments */
 	t = value ? ast_strdupa(value) : "";
 
 	if (!s || !t) {
 		ast_log(LOG_ERROR, "Out of memory\n");
 		AST_LIST_UNLOCK(&queries);
+		if (chan)
+			ast_autoservice_stop(chan);
+		if (bogus_chan)
+			ast_channel_free(chan);
 		return -1;
 	}
 
@@ -232,6 +244,11 @@
 	if (obj)
 		ast_odbc_release_obj(obj);
 
+	if (chan)
+		ast_autoservice_stop(chan);
+	if (bogus_chan)
+		ast_channel_free(chan);
+
 	return 0;
 }
 
@@ -240,7 +257,7 @@
 	struct odbc_obj *obj = NULL;
 	struct acf_odbc_query *query;
 	char sql[2048] = "", varname[15], colnames[2048] = "", rowcount[12] = "-1";
-	int res, x, y, buflen = 0, escapecommas, rowlimit = 1, dsn;
+	int res, x, y, buflen = 0, escapecommas, rowlimit = 1, dsn, bogus_chan = 0;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(field)[100];
 	);
@@ -265,6 +282,14 @@
 		return -1;
 	}
 
+	if (!chan) {
+		if ((chan = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/func_odbc")))
+			bogus_chan = 1;
+	}
+
+	if (chan)
+		ast_autoservice_start(chan);
+
 	AST_STANDARD_APP_ARGS(args, s);
 	for (x = 0; x < args.argc; x++) {
 		snprintf(varname, sizeof(varname), "ARG%d", x + 1);
@@ -306,6 +331,10 @@
 		if (obj)
 			ast_odbc_release_obj(obj);
 		pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
+		if (chan)
+			ast_autoservice_stop(chan);
+		if (bogus_chan)
+			ast_channel_free(chan);
 		return -1;
 	}
 
@@ -316,6 +345,10 @@
 		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
 		ast_odbc_release_obj(obj);
 		pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
+		if (chan)
+			ast_autoservice_stop(chan);
+		if (bogus_chan)
+			ast_channel_free(chan);
 		return -1;
 	}
 
@@ -333,6 +366,10 @@
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 		ast_odbc_release_obj(obj);
 		pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
+		if (chan)
+			ast_autoservice_stop(chan);
+		if (bogus_chan)
+			ast_channel_free(chan);
 		return res1;
 	}
 
@@ -380,6 +417,10 @@
 						SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 						ast_odbc_release_obj(obj);
 						pbx_builtin_setvar_helper(chan, "ODBCROWS", rowcount);
+						if (chan)
+							ast_autoservice_stop(chan);
+						if (bogus_chan)
+							ast_channel_free(chan);
 						return -1;
 					}
 					resultset = tmp;
@@ -456,6 +497,10 @@
 			SQLCloseCursor(stmt);
 			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 			ast_odbc_release_obj(obj);
+			if (chan)
+				ast_autoservice_stop(chan);
+			if (bogus_chan)
+				ast_channel_free(chan);
 			return -1;
 		}
 		odbc_store->data = resultset;
@@ -464,6 +509,10 @@
 	SQLCloseCursor(stmt);
 	SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 	ast_odbc_release_obj(obj);
+	if (chan)
+		ast_autoservice_stop(chan);
+	if (bogus_chan)
+		ast_channel_free(chan);
 	return 0;
 }
 

Modified: trunk/funcs/func_realtime.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_realtime.c?view=diff&rev=87263&r1=87262&r2=87263
==============================================================================
--- trunk/funcs/func_realtime.c (original)
+++ trunk/funcs/func_realtime.c Sun Oct 28 09:11:01 2007
@@ -71,9 +71,14 @@
 	if (!args.delim2)
 		args.delim2 = "=";
 
+	if (chan)
+		ast_autoservice_start(chan);
+
 	head = ast_load_realtime_all(args.family, args.fieldmatch, args.value, NULL);
 
 	if (!head)
+		if (chan)
+			ast_autoservice_stop(chan);
 		return -1;
 
 	resultslen = 0;
@@ -87,6 +92,9 @@
 	for (var = head; var; var = var->next)
 		ast_str_append(&out, 0, "%s%s%s%s", var->name, args.delim2, var->value, args.delim1);
 	ast_copy_string(buf, out->str, len);
+
+	if (chan)
+		ast_autoservice_stop(chan);
 
 	return 0;
 }
@@ -106,6 +114,9 @@
 		return -1;
 	}
 
+	if (chan)
+		ast_autoservice_start(chan);
+
 	AST_STANDARD_APP_ARGS(args, data);
 
 	res = ast_update_realtime(args.family, args.fieldmatch, args.value, args.field, (char *)value, NULL);
@@ -113,6 +124,9 @@
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Failed to update. Check the debug log for possible data repository related entries.\n");
 	}
+
+	if (chan)
+		ast_autoservice_stop(chan);
 
 	return 0;
 }

Modified: trunk/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_strings.c?view=diff&rev=87263&r1=87262&r2=87263
==============================================================================
--- trunk/funcs/func_strings.c (original)
+++ trunk/funcs/func_strings.c Sun Oct 28 09:11:01 2007
@@ -57,6 +57,9 @@
 	char delim[2] = "";
 	size_t delim_used;
 
+	if (chan)
+		ast_autoservice_start(chan);
+
 	AST_STANDARD_APP_ARGS(args, parse);
 	if (args.delim) {
 		ast_get_encoded_char(args.delim, delim, &delim_used);
@@ -75,6 +78,9 @@
 		fieldcount = 1;
 	}
 	snprintf(buf, len, "%d", fieldcount);
+
+	if (chan)
+		ast_autoservice_stop(chan);
 
 	return 0;
 }
@@ -255,13 +261,19 @@
 	if (!var || !value2)
 		return -1;
 
+	if (chan)
+		ast_autoservice_start(chan);
+
 	if (!strcmp(cmd, "HASH")) {
 		const char *var2 = pbx_builtin_getvar_helper(chan, "~ODBCFIELDS~");
 		origvar = var;
 		if (var2)
 			var = ast_strdupa(var2);
-		else
+		else {
+			if (chan)
+				ast_autoservice_stop(chan);
 			return -1;
+		}
 		ishash = 1;
 	}
 
@@ -297,6 +309,9 @@
 			}
 		}
 	}
+
+	if (chan)
+		ast_autoservice_stop(chan);
 
 	return 0;
 }
@@ -726,7 +741,11 @@
 		return -1;
 	}
 
+	if (chan)
+		ast_autoservice_start(chan);
 	pbx_substitute_variables_helper(chan, data, buf, len - 1);
+	if (chan)
+		ast_autoservice_stop(chan);
 
 	return 0;
 }




More information about the asterisk-commits mailing list