aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-24 19:53:43 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-08-24 19:53:43 +0000
commite64409c155774a5adccec4a3d2b1db856d155e5f (patch)
treebfc67c2cf6b6170a2055dfe0b6a1e815f1803cdf
parent8160370dfa80040443be4743cee89343f0426d5c (diff)
Merged revisions 40994 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r40994 | russell | 2006-08-24 15:41:26 -0400 (Thu, 24 Aug 2006) | 11 lines Fix a few issues related to the handling of channel variables - in pbx_builtin_serialize_variables(), the variable list traversal would stop on a variables with empty name/values, which is not appropriate - When removing the GROUP variables, use AST_LIST_REMOVE_CURRENT instead of AST_LIST_REMOVE - During masquerading, when copying the variables list from one channel to the other, using AST_LIST_INSERT_TAIL is not valid for appending a whole list. It leaves the tail pointer of the list invalid. Introduce a new macro, AST_LIST_APPEND_LIST that appends a list properly. (issue #7802, softins) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@40995 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--include/asterisk/linkedlists.h17
-rw-r--r--main/channel.c4
-rw-r--r--main/pbx.c6
3 files changed, 22 insertions, 5 deletions
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h
index fe09610ff..d7447d12f 100644
--- a/include/asterisk/linkedlists.h
+++ b/include/asterisk/linkedlists.h
@@ -462,6 +462,23 @@ struct { \
} while (0)
/*!
+ \brief Appends a whole list to the tail of a list.
+ \param head This is a pointer to the list head structure
+ \param list This is a pointer to the list to be appended.
+ \param field This is the name of the field (declared using AST_LIST_ENTRY())
+ used to link entries of this list together.
+ */
+#define AST_LIST_APPEND_LIST(head, list, field) do { \
+ if (!(head)->first) { \
+ (head)->first = (list)->first; \
+ (head)->last = (list)->last; \
+ } else { \
+ (head)->last->field.next = (list)->first; \
+ (head)->last = (list)->last; \
+ } \
+} while (0)
+
+/*!
\brief Removes and returns the head entry from a list.
\param head This is a pointer to the list head structure
\param field This is the name of the field (declared using AST_LIST_ENTRY())
diff --git a/main/channel.c b/main/channel.c
index 66649bc33..f2cc5fa14 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3046,7 +3046,7 @@ static void clone_variables(struct ast_channel *original, struct ast_channel *cl
AST_LIST_TRAVERSE_SAFE_BEGIN(&original->varshead, varptr, entries) {
if (!strncmp(ast_var_name(varptr), GROUP_CATEGORY_PREFIX, strlen(GROUP_CATEGORY_PREFIX))) {
- AST_LIST_REMOVE(&original->varshead, varptr, entries);
+ AST_LIST_REMOVE_CURRENT(&original->varshead, entries);
ast_var_delete(varptr);
}
}
@@ -3055,7 +3055,7 @@ static void clone_variables(struct ast_channel *original, struct ast_channel *cl
/* Append variables from clone channel into original channel */
/* XXX Is this always correct? We have to in order to keep MACROS working XXX */
if (AST_LIST_FIRST(&clone->varshead))
- AST_LIST_INSERT_TAIL(&original->varshead, AST_LIST_FIRST(&clone->varshead), entries);
+ AST_LIST_APPEND_LIST(&original->varshead, &clone->varshead, entries);
}
/*!
diff --git a/main/pbx.c b/main/pbx.c
index feae6d16d..31f554acd 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -5360,9 +5360,9 @@ int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t
memset(buf, 0, size);
AST_LIST_TRAVERSE(&chan->varshead, variables, entries) {
- if(variables &&
- (var=ast_var_name(variables)) && (val=ast_var_value(variables)) &&
- !ast_strlen_zero(var) && !ast_strlen_zero(val)) {
+ if ((var=ast_var_name(variables)) && (val=ast_var_value(variables))
+ /* && !ast_strlen_zero(var) && !ast_strlen_zero(val) */
+ ) {
if (ast_build_string(&buf, &size, "%s=%s\n", var, val)) {
ast_log(LOG_ERROR, "Data Buffer Size Exceeded!\n");
break;