diff --git a/funcs/func_cut.c b/funcs/func_cut.c index 7b4f0f41d7eac131d7dd5bd67ffa259f08db1f9a..82a564b42c2c83a43083a1de3a7add2025a33a3b 100644 --- a/funcs/func_cut.c +++ b/funcs/func_cut.c @@ -126,7 +126,7 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size ); memset(buffer, 0, buflen); - + parse = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, parse); @@ -235,6 +235,9 @@ static int acf_cut_exec(struct ast_channel *chan, const char *cmd, char *data, c { 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"); @@ -252,6 +255,9 @@ static int acf_cut_exec(struct ast_channel *chan, const char *cmd, char *data, c ast_log(LOG_ERROR, "Unknown internal error\n"); } + if (chan) + ast_autoservice_stop(chan); + return ret; } diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c index f9272fe889149212ee8a0d720fef816af6eda0f5..069eaf7cd539e6a8c503f746b977e69529190ccd 100644 --- a/funcs/func_odbc.c +++ b/funcs/func_odbc.c @@ -139,7 +139,7 @@ static int acf_odbc_write(struct ast_channel *chan, const char *cmd, char *s, co 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 @@ static int acf_odbc_write(struct ast_channel *chan, const char *cmd, char *s, co 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 @@ static int acf_odbc_write(struct ast_channel *chan, const char *cmd, char *s, co 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 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha 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 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha 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 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha 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 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha 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 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha 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 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha 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 @@ end_acf_read: 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 @@ end_acf_read: 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; } diff --git a/funcs/func_realtime.c b/funcs/func_realtime.c index 1f67fcb464086cc27c4af32e5ebcb051f3c74998..bc9063fe9af36abf1d2cd19f83553c436adc6ef3 100644 --- a/funcs/func_realtime.c +++ b/funcs/func_realtime.c @@ -71,9 +71,14 @@ static int function_realtime_read(struct ast_channel *chan, const char *cmd, cha 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; @@ -88,6 +93,9 @@ static int function_realtime_read(struct ast_channel *chan, const char *cmd, cha 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 @@ static int function_realtime_write(struct ast_channel *chan, const char *cmd, ch 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); @@ -114,6 +125,9 @@ static int function_realtime_write(struct ast_channel *chan, const char *cmd, ch 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; } diff --git a/funcs/func_strings.c b/funcs/func_strings.c index 3230b67adcc49f696bf2d9a053379a5640b85364..f4869f4da98c5d619a7fbf737c376777b70776fe 100644 --- a/funcs/func_strings.c +++ b/funcs/func_strings.c @@ -57,6 +57,9 @@ static int function_fieldqty(struct ast_channel *chan, const char *cmd, 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); @@ -76,6 +79,9 @@ static int function_fieldqty(struct ast_channel *chan, const char *cmd, } snprintf(buf, len, "%d", fieldcount); + if (chan) + ast_autoservice_stop(chan); + return 0; } @@ -255,13 +261,19 @@ static int array(struct ast_channel *chan, const char *cmd, char *var, 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; } @@ -298,6 +310,9 @@ static int array(struct ast_channel *chan, const char *cmd, char *var, } } + if (chan) + ast_autoservice_stop(chan); + return 0; } @@ -726,7 +741,11 @@ static int function_eval(struct ast_channel *chan, const char *cmd, char *data, 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; }