[asterisk-commits] dlee: branch dlee/stasis-http r384882 - in /team/dlee/stasis-http: ./ channel...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 8 08:38:35 CDT 2013


Author: dlee
Date: Mon Apr  8 08:38:30 2013
New Revision: 384882

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384882
Log:
Merged revisions 384514-384879 from http://svn.asterisk.org/svn/asterisk/trunk

Dealt with stasis-app merging to trunk.

Added:
    team/dlee/stasis-http/res/res_sorcery_astdb.c
      - copied unchanged from r384857, trunk/res/res_sorcery_astdb.c
    team/dlee/stasis-http/tests/test_sorcery_astdb.c
      - copied unchanged from r384857, trunk/tests/test_sorcery_astdb.c
Modified:
    team/dlee/stasis-http/   (props changed)
    team/dlee/stasis-http/Makefile
    team/dlee/stasis-http/UPGRADE-11.txt
    team/dlee/stasis-http/UPGRADE.txt
    team/dlee/stasis-http/channels/chan_dahdi.c
    team/dlee/stasis-http/channels/chan_sip.c
    team/dlee/stasis-http/channels/sig_pri.c
    team/dlee/stasis-http/channels/sig_pri.h
    team/dlee/stasis-http/configs/chan_dahdi.conf.sample
    team/dlee/stasis-http/funcs/func_channel.c
    team/dlee/stasis-http/include/asterisk/app.h
    team/dlee/stasis-http/main/astobj2.c
    team/dlee/stasis-http/main/event.c
    team/dlee/stasis-http/main/sorcery.c
    team/dlee/stasis-http/main/xmldoc.c

Propchange: team/dlee/stasis-http/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/dlee/stasis-http/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Apr  8 08:38:30 2013
@@ -1,1 +1,1 @@
-/team/dlee/stasis-app:1-384880 /trunk:1-384490
+/trunk:1-384879

Modified: team/dlee/stasis-http/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/Makefile?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/Makefile (original)
+++ team/dlee/stasis-http/Makefile Mon Apr  8 08:38:30 2013
@@ -392,10 +392,11 @@
 	@cmp -s $@.tmp $@ || mv $@.tmp $@
 	@rm -f $@.tmp
 
+# build.h must depend on cleantest, or parallel make may wipe it out after it's
+# been created. But since build.h contains a timestamp, the cmp trick used above
+# won't work. Just testing for existence is good enough.
 include/asterisk/build.h: cleantest
-	@build_tools/make_build_h > $@.tmp
-	@cmp -s $@.tmp $@ || mv $@.tmp $@
-	@rm -f $@.tmp
+	@test -f $@ || build_tools/make_build_h > $@
 
 $(SUBDIRS_CLEAN):
 	+@$(SUBMAKE) -C $(@:-clean=) clean

Modified: team/dlee/stasis-http/UPGRADE-11.txt
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/UPGRADE-11.txt?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/UPGRADE-11.txt (original)
+++ team/dlee/stasis-http/UPGRADE-11.txt Mon Apr  8 08:38:30 2013
@@ -19,6 +19,30 @@
 === UPGRADE-10.txt -- Upgrade info for 1.8 to 10
 ===
 ===========================================================
+
+From 11.4 to 11.5:
+* The default settings for chan_sip are now overriden properly by the general
+  settings in sip.conf.  Please look over your settings upon upgrading.
+
+From 11.3 to 11.4:
+* Added the 'n' option to MeetMe to prevent application of the DENOISE function
+  to a channel joining a conference. Some channel drivers that vary the number
+  of audio samples in a voice frame will experience significant quality problems
+  if a denoiser is attached to the channel; this option gives them the ability
+  to remove the denoiser without having to unload func_speex.
+
+* The Registry AMI event for SIP registrations will now always include the
+  Username field. A previous bug fix missed an instance where it was not
+  included; that has been corrected in this release.
+
+From 11.2.0 to 11.2.1:
+* Asterisk would previously not output certain error messages when a remote
+  console attempted to connect to Asterisk and no instance of Asterisk was
+  running. This error message is displayed on stderr; as a result, some
+  initialization scripts that used remote consoles to test for the presence
+  of a running Asterisk instance started to display erroneous error messages.
+  The init.d scripts and the safe_asterisk have been updated in the contrib
+  folder to account for this.
 
 From 11.2 to 11.3:
 

Modified: team/dlee/stasis-http/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/UPGRADE.txt?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/UPGRADE.txt (original)
+++ team/dlee/stasis-http/UPGRADE.txt Mon Apr  8 08:38:30 2013
@@ -67,6 +67,7 @@
  - Analog port dialing and deferred DTMF dialing for PRI now distinguishes
    between 'w' and 'W'.  The 'w' pauses dialing for half a second.  The 'W'
    pauses dialing for one second.
+ - The default for inband_on_proceeding has changed to no.
 
 Dialplan:
  - All channel and global variable names are evaluated in a case-sensitive manner.
@@ -191,7 +192,7 @@
    configuration option. Symptoms of this include one way media or no media flow.
 
 chan_unistim
- - Due to massive update in chan_unistim phone keys functions and on-screen 
+ - Due to massive update in chan_unistim phone keys functions and on-screen
    information changed.
 
 users.conf:
@@ -263,10 +264,10 @@
    unchanged.
 
 Module Support Level
- - All modules in the addons, apps, bridge, cdr, cel, channels, codecs, 
+ - All modules in the addons, apps, bridge, cdr, cel, channels, codecs,
    formats, funcs, pbx, and res have been updated to include MODULEINFO data
    that includes <support_level> tags with a value of core, extended, or deprecated.
-   More information is available on the Asterisk wiki at 
+   More information is available on the Asterisk wiki at
    https://wiki.asterisk.org/wiki/display/AST/Asterisk+Module+Support+States
 
    Deprecated modules are now marked to not build by default and must be explicitly

Modified: team/dlee/stasis-http/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/channels/chan_dahdi.c?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/channels/chan_dahdi.c (original)
+++ team/dlee/stasis-http/channels/chan_dahdi.c Mon Apr  8 08:38:30 2013
@@ -12951,6 +12951,7 @@
 							pris[span].pri.layer1_ignored = 0;
 						}
 						pris[span].pri.append_msn_to_user_tag = conf->pri.pri.append_msn_to_user_tag;
+						pris[span].pri.inband_on_proceeding = conf->pri.pri.inband_on_proceeding;
 						ast_copy_string(pris[span].pri.initial_user_tag, conf->chan.cid_tag, sizeof(pris[span].pri.initial_user_tag));
 						ast_copy_string(pris[span].pri.msn_list, conf->pri.pri.msn_list, sizeof(pris[span].pri.msn_list));
 #if defined(HAVE_PRI_MWI)
@@ -18218,6 +18219,8 @@
 #endif	/* defined(HAVE_PRI_MWI) */
 			} else if (!strcasecmp(v->name, "append_msn_to_cid_tag")) {
 				confp->pri.pri.append_msn_to_user_tag = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "inband_on_proceeding")) {
+				confp->pri.pri.inband_on_proceeding = ast_true(v->value);
 #if defined(HAVE_PRI_DISPLAY_TEXT)
 			} else if (!strcasecmp(v->name, "display_send")) {
 				confp->pri.pri.display_flags_send = dahdi_display_text_option(v->value);

Modified: team/dlee/stasis-http/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/channels/chan_sip.c?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/channels/chan_sip.c (original)
+++ team/dlee/stasis-http/channels/chan_sip.c Mon Apr  8 08:38:30 2013
@@ -31402,7 +31402,8 @@
 	struct sip_peer *peer;
 	char *cat, *stringp, *context, *oldregcontext;
 	char newcontexts[AST_MAX_CONTEXT], oldcontexts[AST_MAX_CONTEXT];
-	struct ast_flags dummy[3];
+	struct ast_flags mask[3] = {{0}};
+	struct ast_flags setflags[3] = {{0}};
 	struct ast_flags config_flags = { (reason == CHANNEL_MODULE_LOAD || reason == CHANNEL_ACL_RELOAD) ? 0 : ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS) ? 0 : CONFIG_FLAG_FILEUNCHANGED };
 	int auto_sip_domains = FALSE;
 	struct ast_sockaddr old_bindaddr = bindaddr;
@@ -31647,13 +31648,12 @@
 	ast_clear_flag(&global_flags[1], SIP_PAGE2_TEXTSUPPORT);
 	ast_clear_flag(&global_flags[1], SIP_PAGE2_IGNORESDPVERSION);
 
-
 	/* Read the [general] config section of sip.conf (or from realtime config) */
 	for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
-		if (handle_common_options(&global_flags[0], &dummy[0], v)) {
+		if (handle_common_options(&setflags[0], &mask[0], v)) {
 			continue;
 		}
-		if (handle_t38_options(&global_flags[0], &dummy[0], v, &global_t38_maxdatagram)) {
+		if (handle_t38_options(&setflags[0], &mask[0], v, &global_t38_maxdatagram)) {
 			continue;
 		}
 		/* handle jb conf */
@@ -32198,6 +32198,11 @@
 			global_refer_addheaders = ast_true(v->value);
 		}
 	}
+
+	/* Override global defaults if setting found in general section */
+	ast_copy_flags(&global_flags[0], &setflags[0], mask[0].flags);
+	ast_copy_flags(&global_flags[1], &setflags[1], mask[1].flags);
+	ast_copy_flags(&global_flags[2], &setflags[2], mask[2].flags);
 
 	/* For backwards compatibility the corresponding registration timer value is used if subscription timer value isn't set by configuration */
 	if (!min_subexpiry_set) {

Modified: team/dlee/stasis-http/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/channels/sig_pri.c?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/channels/sig_pri.c (original)
+++ team/dlee/stasis-http/channels/sig_pri.c Mon Apr  8 08:38:30 2013
@@ -6752,9 +6752,11 @@
 					/* Bring voice path up */
 					pri_queue_control(pri, chanpos, AST_CONTROL_PROGRESS);
 					pri->pvts[chanpos]->progress = 1;
+					sig_pri_set_dialing(pri->pvts[chanpos], 0);
 					sig_pri_open_media(pri->pvts[chanpos]);
-				}
-				sig_pri_set_dialing(pri->pvts[chanpos], 0);
+				} else if (pri->inband_on_proceeding) {
+					sig_pri_set_dialing(pri->pvts[chanpos], 0);
+				}
 				sig_pri_unlock_private(pri->pvts[chanpos]);
 				break;
 			case PRI_EVENT_FACILITY:

Modified: team/dlee/stasis-http/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/channels/sig_pri.h?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/channels/sig_pri.h (original)
+++ team/dlee/stasis-http/channels/sig_pri.h Mon Apr  8 08:38:30 2013
@@ -470,6 +470,8 @@
 	 * appended to the initial_user_tag[].
 	 */
 	unsigned int append_msn_to_user_tag:1;
+	/*! TRUE if a PROCEEDING message needs to unsquelch the received audio. */
+	unsigned int inband_on_proceeding:1;
 #if defined(HAVE_PRI_MCID)
 	/*! \brief TRUE if allow sending MCID request on this span. */
 	unsigned int mcid_send:1;

Modified: team/dlee/stasis-http/configs/chan_dahdi.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/configs/chan_dahdi.conf.sample?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/configs/chan_dahdi.conf.sample (original)
+++ team/dlee/stasis-http/configs/chan_dahdi.conf.sample Mon Apr  8 08:38:30 2013
@@ -195,6 +195,18 @@
 ; B channels; defaults to 'never'.
 ;
 ;resetinterval = 3600
+;
+; Assume inband audio may be present when a PROCEEDING message is received.
+; Q.931 Section 5.1.2 says the network cannot assume that the CPE side has
+; attached to the B channel at this time without explicitly sending the
+; progress indicator ie informing the CPE side to attach to the B channel
+; for audio.  However, some non-compliant ISDN switches send a PROCEEDING
+; without the progress indicator ie indicating inband audio is available and
+; assume that the CPE device has connected the media path for listening to
+; ringback and other messages.
+; Default no.
+;
+;inband_on_proceeding=yes
 ;
 ; Overlap dialing mode (sending overlap digits)
 ; Cannot be changed on a reload.

Modified: team/dlee/stasis-http/funcs/func_channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/funcs/func_channel.c?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/funcs/func_channel.c (original)
+++ team/dlee/stasis-http/funcs/func_channel.c Mon Apr  8 08:38:30 2013
@@ -77,6 +77,20 @@
 			<parameter name="item" required="true">
 				<para>Standard items (provided by all channel technologies) are:</para>
 				<enumlist>
+					<enum name="amaflags">
+						<para>R/W the Automatic Message Accounting (AMA) flags on the channel.
+						When read from a channel, the integer value will always be returned.
+						When written to a channel, both the string format or integer value
+						is accepted.</para>
+						<enumlist>
+							<enum name="1"><para><literal>OMIT</literal></para></enum>
+							<enum name="2"><para><literal>BILLING</literal></para></enum>
+							<enum name="3"><para><literal>DOCUMENTATION</literal></para></enum>
+						</enumlist>
+					</enum>
+					<enum name="accountcode">
+						<para>R/W the channel's account code.</para>
+					</enum>
 					<enum name="audioreadformat">
 						<para>R/O format currently being read.</para>
 					</enum>

Modified: team/dlee/stasis-http/include/asterisk/app.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/include/asterisk/app.h?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/include/asterisk/app.h (original)
+++ team/dlee/stasis-http/include/asterisk/app.h Mon Apr  8 08:38:30 2013
@@ -864,13 +864,13 @@
   \param parse A modifiable buffer containing the input to be parsed
 
   This function will separate the input string using the standard argument
-  separator character '|' and fill in the provided structure, including
+  separator character ',' and fill in the provided structure, including
   the argc argument counter field.
  */
 #define AST_STANDARD_APP_ARGS(args, parse) \
-	args.argc = __ast_app_separate_args(parse, '|', 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
+	args.argc = __ast_app_separate_args(parse, ',', 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
 #define AST_STANDARD_RAW_ARGS(args, parse) \
-	args.argc = __ast_app_separate_args(parse, '|', 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
+	args.argc = __ast_app_separate_args(parse, ',', 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0])))
 
 /*!
   \brief Performs the 'nonstandard' argument separation process for an application.

Modified: team/dlee/stasis-http/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/main/astobj2.c?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/main/astobj2.c (original)
+++ team/dlee/stasis-http/main/astobj2.c Mon Apr  8 08:38:30 2013
@@ -3468,6 +3468,15 @@
 	}
 }
 
+enum equal_node_bias {
+	/*! Bias search toward first matching node in the container. */
+	BIAS_FIRST,
+	/*! Bias search toward any matching node. */
+	BIAS_EQUAL,
+	/*! Bias search toward last matching node in the container. */
+	BIAS_LAST,
+};
+
 enum empty_node_direction {
 	GO_LEFT,
 	GO_RIGHT,
@@ -3485,10 +3494,11 @@
  *   OBJ_POINTER - if set, 'obj_right', is an object.
  *   OBJ_KEY - if set, 'obj_right', is a search key item that is not an object.
  *   OBJ_PARTIAL_KEY - if set, 'obj_right', is a partial search key item that is not an object.
+ * \param bias How to bias search direction for duplicates
  *
  * \return enum empty_node_direction to proceed.
  */
-static enum empty_node_direction rb_find_empty_direction(struct rbtree_node *empty, ao2_sort_fn *sort_fn, void *obj_right, enum search_flags flags)
+static enum empty_node_direction rb_find_empty_direction(struct rbtree_node *empty, ao2_sort_fn *sort_fn, void *obj_right, enum search_flags flags, enum equal_node_bias bias)
 {
 	int cmp;
 	struct rbtree_node *cur;
@@ -3505,6 +3515,9 @@
 		if (cmp < 0) {
 			return GO_RIGHT;
 		}
+		if (cmp == 0 && bias == BIAS_LAST) {
+			return GO_RIGHT;
+		}
 		return GO_LEFT;
 	}
 
@@ -3516,10 +3529,13 @@
 	cur = rb_node_most_left(empty->right);
 	if (cur->common.obj) {
 		cmp = sort_fn(cur->common.obj, obj_right, flags);
-		if (cmp <= 0) {
-			return GO_RIGHT;
-		}
-		return GO_LEFT;
+		if (cmp > 0) {
+			return GO_LEFT;
+		}
+		if (cmp == 0 && bias == BIAS_FIRST) {
+			return GO_LEFT;
+		}
+		return GO_RIGHT;
 	}
 
 	/*
@@ -3551,6 +3567,9 @@
 		if (cur->common.obj) {
 			cmp = sort_fn(cur->common.obj, obj_right, flags);
 			if (cmp < 0) {
+				return GO_RIGHT;
+			}
+			if (cmp == 0 && bias == BIAS_LAST) {
 				return GO_RIGHT;
 			}
 			return GO_LEFT;
@@ -4185,6 +4204,7 @@
 	struct rbtree_node *next;
 	ao2_sort_fn *sort_fn;
 	uint32_t options;
+	enum equal_node_bias bias;
 
 	if (!self->root) {
 		/* The tree is empty. */
@@ -4194,6 +4214,21 @@
 
 	sort_fn = self->common.sort_fn;
 	options = self->common.options;
+	switch (options & AO2_CONTAINER_ALLOC_OPT_DUPS_MASK) {
+	default:
+	case AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW:
+		if (options & AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN) {
+			bias = BIAS_FIRST;
+		} else {
+			bias = BIAS_LAST;
+		}
+		break;
+	case AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT:
+	case AO2_CONTAINER_ALLOC_OPT_DUPS_OBJ_REJECT:
+	case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE:
+		bias = BIAS_EQUAL;
+		break;
+	}
 
 	/*
 	 * New nodes are always colored red when initially inserted into
@@ -4206,7 +4241,7 @@
 	for (;;) {
 		if (!cur->common.obj) {
 			/* Which direction do we go to insert this node? */
-			if (rb_find_empty_direction(cur, sort_fn, node->common.obj, OBJ_POINTER)
+			if (rb_find_empty_direction(cur, sort_fn, node->common.obj, OBJ_POINTER, bias)
 				== GO_LEFT) {
 				if (cur->left) {
 					cur = cur->left;
@@ -4254,6 +4289,34 @@
 			rb_insert_fixup(self, node);
 			return AO2_CONTAINER_INSERT_NODE_INSERTED;
 		}
+		switch (bias) {
+		case BIAS_FIRST:
+			/* Duplicate nodes unconditionally accepted. */
+			if (cur->left) {
+				cur = cur->left;
+				continue;
+			}
+
+			/* Node becomes a left child */
+			cur->left = node;
+			node->parent = cur;
+			rb_insert_fixup(self, node);
+			return AO2_CONTAINER_INSERT_NODE_INSERTED;
+		case BIAS_EQUAL:
+			break;
+		case BIAS_LAST:
+			/* Duplicate nodes unconditionally accepted. */
+			if (cur->right) {
+				cur = cur->right;
+				continue;
+			}
+
+			/* Node becomes a right child */
+			cur->right = node;
+			node->parent = cur;
+			rb_insert_fixup(self, node);
+			return AO2_CONTAINER_INSERT_NODE_INSERTED;
+		}
 
 		break;
 	}
@@ -4262,50 +4325,8 @@
 	switch (options & AO2_CONTAINER_ALLOC_OPT_DUPS_MASK) {
 	default:
 	case AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW:
-		if (options & AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN) {
-			/* Find first duplicate node. */
-			for (;;) {
-				next = rb_node_prev_full(cur);
-				if (!next) {
-					break;
-				}
-				cmp = sort_fn(next->common.obj, node->common.obj, OBJ_POINTER);
-				if (cmp) {
-					break;
-				}
-				cur = next;
-			}
-			if (!cur->left) {
-				/* Node becomes a left child */
-				cur->left = node;
-			} else {
-				/* Node becomes a right child */
-				cur = rb_node_most_right(cur->left);
-				cur->right = node;
-			}
-		} else {
-			/* Find last duplicate node. */
-			for (;;) {
-				next = rb_node_next_full(cur);
-				if (!next) {
-					break;
-				}
-				cmp = sort_fn(next->common.obj, node->common.obj, OBJ_POINTER);
-				if (cmp) {
-					break;
-				}
-				cur = next;
-			}
-			if (!cur->right) {
-				/* Node becomes a right child */
-				cur->right = node;
-			} else {
-				/* Node becomes a left child */
-				cur = rb_node_most_left(cur->right);
-				cur->left = node;
-			}
-		}
-		break;
+		ast_assert(0);/* Case already handled by BIAS_FIRST/BIAS_LAST. */
+		return AO2_CONTAINER_INSERT_NODE_REJECTED;
 	case AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT:
 		/* Reject all objects with the same key. */
 		return AO2_CONTAINER_INSERT_NODE_REJECTED;
@@ -4545,16 +4566,17 @@
  *   OBJ_KEY - if set, 'obj_right', is a search key item that is not an object.
  *   OBJ_PARTIAL_KEY - if set, 'obj_right', is a partial search key item that is not an object.
  *   OBJ_CONTINUE - if set, return node right before or right after search key if not a match.
+ * \param bias How to bias search direction for duplicates
  *
  * \retval node on success.
  * \retval NULL if not found.
  */
-static struct rbtree_node *rb_find_initial(struct ao2_container_rbtree *self, void *obj_right, enum search_flags flags)
+static struct rbtree_node *rb_find_initial(struct ao2_container_rbtree *self, void *obj_right, enum search_flags flags, enum equal_node_bias bias)
 {
 	int cmp;
 	enum search_flags sort_flags;
 	struct rbtree_node *node;
-	struct rbtree_node *next;
+	struct rbtree_node *next = NULL;
 	ao2_sort_fn *sort_fn;
 
 	sort_flags = flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY);
@@ -4568,13 +4590,34 @@
 	for (;;) {
 		if (!node->common.obj) {
 			/* Which direction do we go to find the node? */
-			if (rb_find_empty_direction(node, sort_fn, obj_right, sort_flags)
+			if (rb_find_empty_direction(node, sort_fn, obj_right, sort_flags, bias)
 				== GO_LEFT) {
 				next = node->left;
 			} else {
 				next = node->right;
 			}
 			if (!next) {
+				switch (bias) {
+				case BIAS_FIRST:
+					/* Check successor node for match. */
+					next = rb_node_next_full(node);
+					break;
+				case BIAS_EQUAL:
+					break;
+				case BIAS_LAST:
+					/* Check previous node for match. */
+					next = rb_node_prev_full(node);
+					break;
+				}
+				if (next) {
+					cmp = sort_fn(next->common.obj, obj_right, sort_flags);
+					if (cmp == 0) {
+						/* Found the first/last matching node. */
+						return next;
+					}
+					next = NULL;
+				}
+
 				/* No match found. */
 				if (flags & OBJ_CONTINUE) {
 					next = rb_node_next_full(node);
@@ -4591,9 +4634,46 @@
 			} else if (cmp < 0) {
 				next = node->right;
 			} else {
-				return node;
+				switch (bias) {
+				case BIAS_FIRST:
+					next = node->left;
+					break;
+				case BIAS_EQUAL:
+					return node;
+				case BIAS_LAST:
+					next = node->right;
+					break;
+				}
+				if (!next) {
+					/* Found the first/last matching node. */
+					return node;
+				}
 			}
 			if (!next) {
+				switch (bias) {
+				case BIAS_FIRST:
+					if (cmp < 0) {
+						/* Check successor node for match. */
+						next = rb_node_next_full(node);
+					}
+					break;
+				case BIAS_EQUAL:
+					break;
+				case BIAS_LAST:
+					if (cmp > 0) {
+						/* Check previous node for match. */
+						next = rb_node_prev_full(node);
+					}
+					break;
+				}
+				if (next) {
+					cmp = sort_fn(next->common.obj, obj_right, sort_flags);
+					if (cmp == 0) {
+						/* Found the first/last matching node. */
+						return next;
+					}
+				}
+
 				/* No match found. */
 				if (flags & OBJ_CONTINUE) {
 					return node;
@@ -4620,9 +4700,8 @@
  */
 static struct rbtree_node *rb_ao2_find_first(struct ao2_container_rbtree *self, enum search_flags flags, void *arg, struct rbtree_traversal_state *state)
 {
-	struct rbtree_node *next;
 	struct rbtree_node *node;
-	int cmp;
+	enum equal_node_bias bias;
 
 	if (self->common.destroying) {
 		/* Force traversal to be post order for tree destruction. */
@@ -4663,32 +4742,25 @@
 		}
 
 		/* Search for initial node. */
-		node = rb_find_initial(self, arg, flags);
-		if (!node) {
-			return NULL;
-		}
 		switch (self->common.options & AO2_CONTAINER_ALLOC_OPT_DUPS_MASK) {
+		case AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT:
+		case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE:
+			if ((flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) != OBJ_PARTIAL_KEY) {
+				/* There are no duplicates allowed. */
+				bias = BIAS_EQUAL;
+				break;
+			}
+			/* Fall through */
 		default:
 		case AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW:
 		case AO2_CONTAINER_ALLOC_OPT_DUPS_OBJ_REJECT:
 			/* Find first duplicate node. */
-			for (;;) {
-				next = rb_node_prev_full(node);
-				if (!next) {
-					break;
-				}
-				cmp = state->sort_fn(next->common.obj, arg,
-					flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY));
-				if (cmp) {
-					break;
-				}
-				node = next;
-			}
+			bias = BIAS_FIRST;
 			break;
-		case AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT:
-		case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE:
-			/* There are no duplicates allowed. */
-			break;
+		}
+		node = rb_find_initial(self, arg, flags, bias);
+		if (!node) {
+			return NULL;
 		}
 		break;
 	case OBJ_ORDER_DESCENDING:
@@ -4705,32 +4777,25 @@
 		}
 
 		/* Search for initial node. */
-		node = rb_find_initial(self, arg, flags);
-		if (!node) {
-			return NULL;
-		}
 		switch (self->common.options & AO2_CONTAINER_ALLOC_OPT_DUPS_MASK) {
+		case AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT:
+		case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE:
+			if ((flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) != OBJ_PARTIAL_KEY) {
+				/* There are no duplicates allowed. */
+				bias = BIAS_EQUAL;
+				break;
+			}
+			/* Fall through */
 		default:
 		case AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW:
 		case AO2_CONTAINER_ALLOC_OPT_DUPS_OBJ_REJECT:
 			/* Find last duplicate node. */
-			for (;;) {
-				next = rb_node_next_full(node);
-				if (!next) {
-					break;
-				}
-				cmp = state->sort_fn(next->common.obj, arg,
-					flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY));
-				if (cmp) {
-					break;
-				}
-				node = next;
-			}
+			bias = BIAS_LAST;
 			break;
-		case AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT:
-		case AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE:
-			/* There are no duplicates allowed. */
-			break;
+		}
+		node = rb_find_initial(self, arg, flags, bias);
+		if (!node) {
+			return NULL;
 		}
 		break;
 	case OBJ_ORDER_PRE:

Modified: team/dlee/stasis-http/main/event.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/main/event.c?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/main/event.c (original)
+++ team/dlee/stasis-http/main/event.c Mon Apr  8 08:38:30 2013
@@ -152,10 +152,7 @@
 
 #define MAX_CACHE_ARGS 8
 
-/*!
- * \brief Event types that are kept in the cache.
- */
-static struct {
+struct cache_events {
 	/*!
 	 * \brief Container of cached events
 	 *
@@ -174,7 +171,12 @@
 	 * will be replaced.
 	 */
 	enum ast_event_ie_type cache_args[MAX_CACHE_ARGS];
-} ast_event_cache[AST_EVENT_TOTAL] = {
+};
+
+/*!
+ * \brief Event types that are kept in the cache.
+ */
+static struct cache_events ast_event_cache[AST_EVENT_TOTAL] = {
 	[AST_EVENT_MWI] = {
 		.hash_fn = ast_event_hash_mwi,
 		.cache_args = { AST_EVENT_IE_MAILBOX, AST_EVENT_IE_CONTEXT },
@@ -191,7 +193,6 @@
 		.hash_fn = ast_event_hash_presence_state_change,
 		.cache_args = { AST_EVENT_IE_PRESENCE_STATE, },
 	},
-
 };
 
 /*!
@@ -218,13 +219,15 @@
 	[AST_EVENT_PRESENCE_STATE]      = "PresenceState",
 };
 
+struct ie_map {
+	enum ast_event_ie_pltype ie_pltype;
+	const char *name;
+};
+
 /*!
  * \brief IE payload types and names
  */
-static const struct ie_map {
-	enum ast_event_ie_pltype ie_pltype;
-	const char *name;
-} ie_maps[AST_EVENT_IE_TOTAL] = {
+static const struct ie_map ie_maps[AST_EVENT_IE_TOTAL] = {
 	[AST_EVENT_IE_NEWMSGS]             = { AST_EVENT_IE_PLTYPE_UINT, "NewMessages" },
 	[AST_EVENT_IE_OLDMSGS]             = { AST_EVENT_IE_PLTYPE_UINT, "OldMessages" },
 	[AST_EVENT_IE_MAILBOX]             = { AST_EVENT_IE_PLTYPE_STR,  "Mailbox" },

Modified: team/dlee/stasis-http/main/sorcery.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/main/sorcery.c?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/main/sorcery.c (original)
+++ team/dlee/stasis-http/main/sorcery.c Mon Apr  8 08:38:30 2013
@@ -475,6 +475,7 @@
 		return -1;
 	}
 
+	object_type->type.name = object_type->name;
 	object_type->type.type = ACO_ITEM;
 	object_type->type.category = "";
 	object_type->type.item_alloc = alloc;

Modified: team/dlee/stasis-http/main/xmldoc.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/main/xmldoc.c?view=diff&rev=384882&r1=384881&r2=384882
==============================================================================
--- team/dlee/stasis-http/main/xmldoc.c (original)
+++ team/dlee/stasis-http/main/xmldoc.c Mon Apr  8 08:38:30 2013
@@ -709,13 +709,13 @@
 	}
 
 	/* Get the argument separator from the root node attribute name 'argsep', if not found
-	defaults to '|'. */
+	defaults to ','. */
 	attrargsep = ast_xml_get_attribute(rootnode, "argsep");
 	if (attrargsep) {
 		argsep = ast_strdupa(attrargsep);
 		ast_xml_free_attr(attrargsep);
 	} else {
-		argsep = ast_strdupa("|");
+		argsep = ast_strdupa(",");
 	}
 
 	/* Get order of evaluation. */




More information about the asterisk-commits mailing list