[svn-commits] russell: branch 1.2 r40994 - in /branches/1.2: ./ include/asterisk/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Thu Aug 24 12:41:26 MST 2006


Author: russell
Date: Thu Aug 24 14:41:26 2006
New Revision: 40994

URL: http://svn.digium.com/view/asterisk?rev=40994&view=rev
Log:
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)

Modified:
    branches/1.2/channel.c
    branches/1.2/include/asterisk/linkedlists.h
    branches/1.2/pbx.c

Modified: branches/1.2/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channel.c?rev=40994&r1=40993&r2=40994&view=diff
==============================================================================
--- branches/1.2/channel.c (original)
+++ branches/1.2/channel.c Thu Aug 24 14:41:26 2006
@@ -2891,7 +2891,7 @@
 
 	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);
 		}
 	}
@@ -2900,7 +2900,7 @@
 	/* 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);
 }
 
 /*--- ast_do_masquerade: Masquerade a channel */

Modified: branches/1.2/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/branches/1.2/include/asterisk/linkedlists.h?rev=40994&r1=40993&r2=40994&view=diff
==============================================================================
--- branches/1.2/include/asterisk/linkedlists.h (original)
+++ branches/1.2/include/asterisk/linkedlists.h Thu Aug 24 14:41:26 2006
@@ -430,6 +430,23 @@
 } 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())

Modified: branches/1.2/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/pbx.c?rev=40994&r1=40993&r2=40994&view=diff
==============================================================================
--- branches/1.2/pbx.c (original)
+++ branches/1.2/pbx.c Thu Aug 24 14:41:26 2006
@@ -5906,9 +5906,7 @@
 	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))) {
 			if (ast_build_string(&buf, &size, "%s=%s\n", var, val)) {
 				ast_log(LOG_ERROR, "Data Buffer Size Exceeded!\n");
 				break;



More information about the svn-commits mailing list