[asterisk-commits] russell: branch russell/ast_channel_ao2 r174145 - /team/russell/ast_channel_a...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Feb 7 06:52:04 CST 2009
Author: russell
Date: Sat Feb 7 06:52:03 2009
New Revision: 174145
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=174145
Log:
convert func_logic, func_global, and func_channel
Modified:
team/russell/ast_channel_ao2/funcs/func_channel.c
team/russell/ast_channel_ao2/funcs/func_global.c
team/russell/ast_channel_ao2/funcs/func_logic.c
Modified: team/russell/ast_channel_ao2/funcs/func_channel.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/funcs/func_channel.c?view=diff&rev=174145&r1=174144&r2=174145
==============================================================================
--- team/russell/ast_channel_ao2/funcs/func_channel.c (original)
+++ team/russell/ast_channel_ao2/funcs/func_channel.c Sat Feb 7 06:52:03 2009
@@ -340,7 +340,8 @@
regex_t re;
int res;
size_t buflen = 0;
-
+ struct ast_channel_iterator *iter;
+
buf[0] = '\0';
if (!ast_strlen_zero(data)) {
@@ -351,7 +352,15 @@
}
}
- for (c = ast_channel_walk_locked(NULL); c; ast_channel_unlock(c), c = ast_channel_walk_locked(c)) {
+ if (!(iter = ast_channel_iterator_all_new(0))) {
+ if (!ast_strlen_zero(data)) {
+ regfree(&re);
+ }
+ return -1;
+ }
+
+ while ((c = ast_channel_iterator_next(iter))) {
+ ast_channel_lock(c);
if (ast_strlen_zero(data) || regexec(&re, c->name, 0, NULL, 0) == 0) {
size_t namelen = strlen(c->name);
if (buflen + namelen + (ast_strlen_zero(buf) ? 0 : 1) + 1 < maxlen) {
@@ -365,7 +374,11 @@
ast_log(LOG_WARNING, "Number of channels exceeds the available buffer space. Output will be truncated!\n");
}
}
- }
+ ast_channel_unlock(c);
+ c = ast_channel_unref(c);
+ }
+
+ ast_channel_iterator_destroy(iter);
if (!ast_strlen_zero(data)) {
regfree(&re);
Modified: team/russell/ast_channel_ao2/funcs/func_global.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/funcs/func_global.c?view=diff&rev=174145&r1=174144&r2=174145
==============================================================================
--- team/russell/ast_channel_ao2/funcs/func_global.c (original)
+++ team/russell/ast_channel_ao2/funcs/func_global.c Sat Feb 7 06:52:03 2009
@@ -134,6 +134,7 @@
AST_APP_ARG(var);
AST_APP_ARG(chan);
);
+ struct ast_channel *c_ref = NULL;
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "SHARED() requires an argument: SHARED(<var>[,<chan>])\n");
@@ -145,15 +146,21 @@
if (!ast_strlen_zero(args.chan)) {
char *prefix = alloca(strlen(args.chan) + 2);
sprintf(prefix, "%s-", args.chan);
- if (!(chan = ast_get_channel_by_name_locked(args.chan)) && !(chan = ast_get_channel_by_name_prefix_locked(prefix, strlen(prefix)))) {
+ if (!(c_ref = ast_channel_get_by_name(args.chan)) && !(c_ref = ast_channel_get_by_name_prefix(prefix, strlen(prefix)))) {
ast_log(LOG_ERROR, "Channel '%s' not found! Variable '%s' will be blank.\n", args.chan, args.var);
return -1;
}
- } else
- ast_channel_lock(chan);
+ chan = c_ref;
+ ast_channel_lock(chan);
+ } else {
+ ast_channel_lock(chan);
+ }
if (!(varstore = ast_channel_datastore_find(chan, &shared_variable_info, NULL))) {
ast_channel_unlock(chan);
+ if (c_ref) {
+ c_ref = ast_channel_unref(c_ref);
+ }
return -1;
}
@@ -169,6 +176,10 @@
}
ast_channel_unlock(chan);
+
+ if (c_ref) {
+ c_ref = ast_channel_unref(c_ref);
+ }
return 0;
}
@@ -182,6 +193,7 @@
AST_APP_ARG(var);
AST_APP_ARG(chan);
);
+ struct ast_channel *c_ref = NULL;
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "SHARED() requires an argument: SHARED(<var>[,<chan>])\n");
@@ -193,17 +205,23 @@
if (!ast_strlen_zero(args.chan)) {
char *prefix = alloca(strlen(args.chan) + 2);
sprintf(prefix, "%s-", args.chan);
- if (!(chan = ast_get_channel_by_name_locked(args.chan)) && !(chan = ast_get_channel_by_name_prefix_locked(prefix, strlen(prefix)))) {
+ if (!(c_ref = ast_channel_get_by_name(args.chan)) && !(c_ref = ast_channel_get_by_name_prefix(prefix, strlen(prefix)))) {
ast_log(LOG_ERROR, "Channel '%s' not found! Variable '%s' not set to '%s'.\n", args.chan, args.var, value);
return -1;
}
- } else
- ast_channel_lock(chan);
+ chan = c_ref;
+ ast_channel_lock(chan);
+ } else {
+ ast_channel_lock(chan);
+ }
if (!(varstore = ast_channel_datastore_find(chan, &shared_variable_info, NULL))) {
if (!(varstore = ast_datastore_alloc(&shared_variable_info, NULL))) {
ast_log(LOG_ERROR, "Unable to allocate new datastore. Shared variable not set.\n");
ast_channel_unlock(chan);
+ if (c_ref) {
+ c_ref = ast_channel_unref(c_ref);
+ }
return -1;
}
@@ -211,6 +229,9 @@
ast_log(LOG_ERROR, "Unable to allocate variable structure. Shared variable not set.\n");
ast_datastore_free(varstore);
ast_channel_unlock(chan);
+ if (c_ref) {
+ c_ref = ast_channel_unref(c_ref);
+ }
return -1;
}
@@ -241,6 +262,10 @@
ast_channel_unlock(chan);
+ if (c_ref) {
+ c_ref = ast_channel_unref(c_ref);
+ }
+
return 0;
}
Modified: team/russell/ast_channel_ao2/funcs/func_logic.c
URL: http://svn.digium.com/svn-view/asterisk/team/russell/ast_channel_ao2/funcs/func_logic.c?view=diff&rev=174145&r1=174144&r2=174145
==============================================================================
--- team/russell/ast_channel_ao2/funcs/func_logic.c (original)
+++ team/russell/ast_channel_ao2/funcs/func_logic.c Sat Feb 7 06:52:03 2009
@@ -230,18 +230,22 @@
AST_APP_ARG(varname);
);
AST_STANDARD_APP_ARGS(args, data);
- buf[0] = 0;
+
+ buf[0] = '\0';
+
if (!ast_strlen_zero(args.varname)) {
- struct ast_channel *chan2 = ast_get_channel_by_name_locked(args.channel);
- if (chan2) {
+ struct ast_channel *chan2;
+
+ if ((chan2 = ast_channel_get_by_name(args.channel))) {
char *s = alloca(strlen(args.varname) + 4);
- if (s) {
- sprintf(s, "${%s}", args.varname);
- pbx_substitute_variables_helper(chan2, s, buf, len);
- }
+ sprintf(s, "${%s}", args.varname);
+ ast_channel_lock(chan2);
+ pbx_substitute_variables_helper(chan2, s, buf, len);
ast_channel_unlock(chan2);
+ chan2 = ast_channel_unref(chan2);
}
}
+
return 0;
}
More information about the asterisk-commits
mailing list