[asterisk-commits] oej: branch oej/applefrog-early-media-in-originate-trunk r342756 - in /team/o...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Oct 31 04:46:02 CDT 2011


Author: oej
Date: Mon Oct 31 04:45:45 2011
New Revision: 342756

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=342756
Log:
Reset branch

Added:
    team/oej/applefrog-early-media-in-originate-trunk/utils/astdb2bdb.c
      - copied unchanged from r342716, trunk/utils/astdb2bdb.c
Modified:
    team/oej/applefrog-early-media-in-originate-trunk/   (props changed)
    team/oej/applefrog-early-media-in-originate-trunk/CHANGES
    team/oej/applefrog-early-media-in-originate-trunk/Makefile
    team/oej/applefrog-early-media-in-originate-trunk/Makefile.moddir_rules
    team/oej/applefrog-early-media-in-originate-trunk/UPGRADE.txt
    team/oej/applefrog-early-media-in-originate-trunk/addons/chan_ooh323.c
    team/oej/applefrog-early-media-in-originate-trunk/addons/ooh323c/src/memheap.c
    team/oej/applefrog-early-media-in-originate-trunk/apps/app_dial.c
    team/oej/applefrog-early-media-in-originate-trunk/apps/app_fax.c
    team/oej/applefrog-early-media-in-originate-trunk/apps/app_meetme.c
    team/oej/applefrog-early-media-in-originate-trunk/apps/app_queue.c
    team/oej/applefrog-early-media-in-originate-trunk/apps/app_url.c
    team/oej/applefrog-early-media-in-originate-trunk/apps/app_voicemail.c
    team/oej/applefrog-early-media-in-originate-trunk/autoconf/ast_ext_lib.m4
    team/oej/applefrog-early-media-in-originate-trunk/build_tools/embed_modules.xml
    team/oej/applefrog-early-media-in-originate-trunk/build_tools/prep_tarball
    team/oej/applefrog-early-media-in-originate-trunk/channels/chan_dahdi.c
    team/oej/applefrog-early-media-in-originate-trunk/channels/chan_gtalk.c
    team/oej/applefrog-early-media-in-originate-trunk/channels/chan_iax2.c
    team/oej/applefrog-early-media-in-originate-trunk/channels/chan_mgcp.c
    team/oej/applefrog-early-media-in-originate-trunk/channels/chan_sip.c
    team/oej/applefrog-early-media-in-originate-trunk/channels/chan_skinny.c
    team/oej/applefrog-early-media-in-originate-trunk/channels/chan_unistim.c
    team/oej/applefrog-early-media-in-originate-trunk/channels/sig_analog.c
    team/oej/applefrog-early-media-in-originate-trunk/channels/sig_pri.c
    team/oej/applefrog-early-media-in-originate-trunk/channels/sig_ss7.c
    team/oej/applefrog-early-media-in-originate-trunk/channels/sig_ss7.h
    team/oej/applefrog-early-media-in-originate-trunk/channels/sip/include/dialog.h
    team/oej/applefrog-early-media-in-originate-trunk/channels/sip/include/sip.h
    team/oej/applefrog-early-media-in-originate-trunk/configs/queues.conf.sample
    team/oej/applefrog-early-media-in-originate-trunk/configure
    team/oej/applefrog-early-media-in-originate-trunk/configure.ac
    team/oej/applefrog-early-media-in-originate-trunk/doc/appdocsxml.dtd
    team/oej/applefrog-early-media-in-originate-trunk/funcs/func_callerid.c
    team/oej/applefrog-early-media-in-originate-trunk/funcs/func_jitterbuffer.c
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/astobj2.h
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/autoconfig.h.in
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/config.h
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/features.h
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/linkedlists.h
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/manager.h
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/module.h
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/res_fax.h
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/sha1.h
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/strings.h
    team/oej/applefrog-early-media-in-originate-trunk/include/asterisk/xmldoc.h
    team/oej/applefrog-early-media-in-originate-trunk/main/astobj2.c
    team/oej/applefrog-early-media-in-originate-trunk/main/channel.c
    team/oej/applefrog-early-media-in-originate-trunk/main/config.c
    team/oej/applefrog-early-media-in-originate-trunk/main/db.c
    team/oej/applefrog-early-media-in-originate-trunk/main/dsp.c
    team/oej/applefrog-early-media-in-originate-trunk/main/features.c
    team/oej/applefrog-early-media-in-originate-trunk/main/loader.c
    team/oej/applefrog-early-media-in-originate-trunk/main/manager.c
    team/oej/applefrog-early-media-in-originate-trunk/main/pbx.c
    team/oej/applefrog-early-media-in-originate-trunk/main/say.c
    team/oej/applefrog-early-media-in-originate-trunk/main/sha1.c
    team/oej/applefrog-early-media-in-originate-trunk/main/udptl.c
    team/oej/applefrog-early-media-in-originate-trunk/main/xmldoc.c
    team/oej/applefrog-early-media-in-originate-trunk/pbx/pbx_lua.c
    team/oej/applefrog-early-media-in-originate-trunk/pbx/pbx_realtime.c
    team/oej/applefrog-early-media-in-originate-trunk/pbx/pbx_spool.c
    team/oej/applefrog-early-media-in-originate-trunk/res/res_agi.c
    team/oej/applefrog-early-media-in-originate-trunk/res/res_calendar.c
    team/oej/applefrog-early-media-in-originate-trunk/res/res_config_sqlite.c
    team/oej/applefrog-early-media-in-originate-trunk/res/res_fax.c
    team/oej/applefrog-early-media-in-originate-trunk/res/res_jabber.c
    team/oej/applefrog-early-media-in-originate-trunk/res/res_rtp_asterisk.c
    team/oej/applefrog-early-media-in-originate-trunk/res/res_rtp_multicast.c
    team/oej/applefrog-early-media-in-originate-trunk/tests/test_format_api.c
    team/oej/applefrog-early-media-in-originate-trunk/tests/test_linkedlists.c
    team/oej/applefrog-early-media-in-originate-trunk/utils/Makefile
    team/oej/applefrog-early-media-in-originate-trunk/utils/utils.xml

Propchange: team/oej/applefrog-early-media-in-originate-trunk/
------------------------------------------------------------------------------
    automerge = Is-there-life-off-net?

Propchange: team/oej/applefrog-early-media-in-originate-trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Propchange: team/oej/applefrog-early-media-in-originate-trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Oct 31 04:45:45 2011
@@ -1,1 +1,1 @@
-/trunk:1-339173
+/trunk:1-342755

Modified: team/oej/applefrog-early-media-in-originate-trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/CHANGES?view=diff&rev=342756&r1=342755&r2=342756
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/CHANGES (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/CHANGES Mon Oct 31 04:45:45 2011
@@ -40,11 +40,18 @@
 -----------------------------
  * Added command "cdr show pgsql status" to check connection status
 
-AMI - the manager interface
----------------------------
+AMI (Asterisk Manager Interface) changes
+----------------------------------------
+ * Originate now generates an error response if the extension given
+   is not found in the dialplan
  * The originate action now has an option "Earlymedia" that enables the
    call to bridge when we get early media in the call. Previously,
    early media was disregarded always when originating calls using AMI.
+
+FAX changes
+-----------
+ * FAXOPT(faxdetect) will enable a generic fax detect framehook for dialplan
+   control of faxdetect.
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.8 to Asterisk 10 -------------------
@@ -126,6 +133,13 @@
  * Ability to read raw signed linear files with sample rates
    ranging from 8khz - 192khz.  The new file extensions introduced
    are .sln12, .sln24, .sln32, .sln44, .sln48, .sln96, .sln192.
+ * Due to protocol limitations, channel drivers other than SIP (eg. IAX2, MGCP,
+   Skinny, H.323, etc) can still only support the following codecs:
+   Audio: ulaw, alaw, slin, slin16, g719, g722, g723, g726, g726aal2, g729, gsm,
+          siren7, siren14, speex, speex16, ilbc, lpc10, adpcm
+   Video: h261, h263, h263p, h264, mpeg4
+   Image: jpeg, png
+   Text:  red, t140
 
 ConfBridge
 --------------------------
@@ -243,6 +257,8 @@
  * Added member option ignorebusy this when set and ringinuse is not
    will allow per member control of multiple calls as ringinuse does for
    the Queue.
+ * Added global option check_state_unknown to enforce checking of device state
+   when the device state is unknown app_queue will see unknown as available.
 
 Applications
 ------------

Modified: team/oej/applefrog-early-media-in-originate-trunk/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/Makefile?view=diff&rev=342756&r1=342755&r2=342756
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/Makefile (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/Makefile Mon Oct 31 04:45:45 2011
@@ -556,6 +556,7 @@
 	$(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/phoneprov"
 	$(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http"
 	$(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/sounds"
+	$(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/moh"
 	$(INSTALL) -d "$(DESTDIR)$(ASTMANDIR)/man8"
 	$(INSTALL) -d "$(DESTDIR)$(AGI_DIR)"
 	$(INSTALL) -d "$(DESTDIR)$(ASTDBDIR)"

Modified: team/oej/applefrog-early-media-in-originate-trunk/Makefile.moddir_rules
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/Makefile.moddir_rules?view=diff&rev=342756&r1=342755&r2=342756
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/Makefile.moddir_rules (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/Makefile.moddir_rules Mon Oct 31 04:45:45 2011
@@ -1,6 +1,6 @@
 #
 # Asterisk -- A telephony toolkit for Linux.
-# 
+#
 # Makefile rules for subdirectories containing modules
 #
 # Copyright (C) 2006, Digium, Inc.
@@ -46,7 +46,7 @@
 C_MODS:=$(filter-out $(MENUSELECT_$(MENUSELECT_CATEGORY)),$(ALL_C_MODS))
 CC_MODS:=$(filter-out $(MENUSELECT_$(MENUSELECT_CATEGORY)),$(ALL_CC_MODS))
 
-ifneq ($(findstring $(MENUSELECT_CATEGORY),$(MENUSELECT_EMBED)),)
+ifneq ($(findstring EMBED_$(MENUSELECT_CATEGORY),$(MENUSELECT_EMBED)),)
     EMBEDDED_MODS:=$(C_MODS) $(CC_MODS)
 else
     LOADABLE_MODS:=$(C_MODS) $(CC_MODS)

Modified: team/oej/applefrog-early-media-in-originate-trunk/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/UPGRADE.txt?view=diff&rev=342756&r1=342755&r2=342756
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/UPGRADE.txt (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/UPGRADE.txt Mon Oct 31 04:45:45 2011
@@ -35,6 +35,10 @@
    - cdr.conf: [general] and [csv] sections
    - dnsmgr.conf
    - dsp.conf
+
+AMI:
+  - DBDelTree now correctly returns an error when 0 rows are deleted just as
+    the DBDel action does.
 
 SIP
 ===
@@ -87,7 +91,9 @@
    SQLite 3. An existing Berkeley astdb file can be converted with the astdb2sqlite3
    utility in the UTILS section of menuselect. If an existing astdb is found and no
    astdb.sqlite3 exists, astdb2sqlite3 will be compiled automatically. Asterisk will
-   convert an existing astdb to the SQLite3 version automatically at runtime.
+   convert an existing astdb to the SQLite3 version automatically at runtime. If
+   moving back from Asterisk 10 to Asterisk 1.8, the astdb2bdb utility can be used
+   to create a Berkeley DB copy of the SQLite3 astdb that Asterisk 10 uses.
 
 Manager:
  - The AMI protocol version was incremented to 1.2 as a result of changing two

Modified: team/oej/applefrog-early-media-in-originate-trunk/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/addons/chan_ooh323.c?view=diff&rev=342756&r1=342755&r2=342756
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/addons/chan_ooh323.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/addons/chan_ooh323.c Mon Oct 31 04:45:45 2011
@@ -367,10 +367,10 @@
 	ast_format_clear(&tmpfmt);
 	/* Don't hold a h323 pvt lock while we allocate a channel */
 	ast_mutex_unlock(&i->lock);
+   	ast_mutex_lock(&ooh323c_cn_lock);
    	ch = ast_channel_alloc(1, state, i->callerid_num, i->callerid_name, 
 				i->accountcode, i->exten, i->context, linkedid, i->amaflags,
 				"OOH323/%s-%ld", host, callnumber);
-   	ast_mutex_lock(&ooh323c_cn_lock);
    	callnumber++;
    	ast_mutex_unlock(&ooh323c_cn_lock);
    

Modified: team/oej/applefrog-early-media-in-originate-trunk/addons/ooh323c/src/memheap.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/addons/ooh323c/src/memheap.c?view=diff&rev=342756&r1=342755&r2=342756
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/addons/ooh323c/src/memheap.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/addons/ooh323c/src/memheap.c Mon Oct 31 04:45:45 2011
@@ -1062,6 +1062,7 @@
 void memHeapRelease (void** ppvMemHeap)
 {
    OSMemHeap** ppMemHeap = (OSMemHeap**)ppvMemHeap;
+   OSMemHeap* pMemHeap = *ppMemHeap;
 
    if (ppMemHeap != 0 && *ppMemHeap != 0 && --(*ppMemHeap)->refCnt == 0) {
       OSMemLink* pMemLink, *pMemLink2;

Modified: team/oej/applefrog-early-media-in-originate-trunk/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/apps/app_dial.c?view=diff&rev=342756&r1=342755&r2=342756
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/apps/app_dial.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/apps/app_dial.c Mon Oct 31 04:45:45 2011
@@ -165,7 +165,9 @@
 					<note>
 						<para>Any channel variables you want the called channel to inherit from the caller channel must be
 						prefixed with one or two underbars ('_').</para>
-						<para>Additionally, using this option from a Macro() or GoSub() might not make sense as there would be no return points</para>
+					</note>
+					<note>
+						<para>Using this option from a Macro() or GoSub() might not make sense as there would be no return points.</para>
 					</note>
 				</option>
 				<option name="g">

Modified: team/oej/applefrog-early-media-in-originate-trunk/apps/app_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/apps/app_fax.c?view=diff&rev=342756&r1=342755&r2=342756
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/apps/app_fax.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/apps/app_fax.c Mon Oct 31 04:45:45 2011
@@ -46,7 +46,7 @@
 #include "asterisk/manager.h"
 
 /*** DOCUMENTATION
-	<application name="SendFAX" language="en_US">
+	<application name="SendFAX" language="en_US" module="app_fax">
 		<synopsis>
 			Send a Fax
 		</synopsis>
@@ -91,7 +91,7 @@
 			</variablelist>
 		</description>
 	</application>
-	<application name="ReceiveFAX" language="en_US">
+	<application name="ReceiveFAX" language="en_US" module="app_fax">
 		<synopsis>
 			Receive a Fax
 		</synopsis>

Modified: team/oej/applefrog-early-media-in-originate-trunk/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/apps/app_meetme.c?view=diff&rev=342756&r1=342755&r2=342756
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/apps/app_meetme.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/apps/app_meetme.c Mon Oct 31 04:45:45 2011
@@ -147,10 +147,13 @@
 					</option>
 					<option name="p" hasparams="optional">
 						<para>Allow user to exit the conference by pressing <literal>#</literal> (default)
-						or any of the defined keys. If keys contain <literal>*</literal> this will override
-						option <literal>s</literal>. The key used is set to channel variable
+						or any of the defined keys.  The key used is set to channel variable
 						<variable>MEETME_EXIT_KEY</variable>.</para>
 						<argument name="keys" required="true" />
+						<note>
+							<para>Option <literal>s</literal> has priority for <literal>*</literal>
+							since it cannot change its activation code.</para>
+						</note>
 					</option>
 					<option name="P">
 						<para>Always prompt for the pin even if it is specified.</para>
@@ -192,6 +195,10 @@
 						<para>Allow user to exit the conference by entering a valid single digit
 						extension <variable>MEETME_EXIT_CONTEXT</variable> or the current context
 						if that variable is not defined.</para>
+						<note>
+							<para>Option <literal>s</literal> has priority for <literal>*</literal>
+							since it cannot change its activation code.</para>
+						</note>
 					</option>
 					<option name="1">
 						<para>Do not play message when first person enters</para>
@@ -3636,7 +3643,10 @@
 					}
 
 					conf_flush(fd, chan);
-				/* Since this option could absorb DTMF meant for the previous (menu), we have to check this one last */
+				/*
+				 * Since options using DTMF could absorb DTMF meant for the
+				 * conference menu, we have to check them after the menu.
+				 */
 				} else if ((f->frametype == AST_FRAME_DTMF) && ast_test_flag64(confflags, CONFFLAG_EXIT_CONTEXT) && ast_exists_extension(chan, exitcontext, dtmfstr, 1, "")) {
 					if (ast_test_flag64(confflags, CONFFLAG_PASS_DTMF)) {
 						conf_queue_dtmf(conf, user, f);

Modified: team/oej/applefrog-early-media-in-originate-trunk/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/applefrog-early-media-in-originate-trunk/apps/app_queue.c?view=diff&rev=342756&r1=342755&r2=342756
==============================================================================
--- team/oej/applefrog-early-media-in-originate-trunk/apps/app_queue.c (original)
+++ team/oej/applefrog-early-media-in-originate-trunk/apps/app_queue.c Mon Oct 31 04:45:45 2011
@@ -957,6 +957,9 @@
 /*! \brief queues.conf [general] option */
 static int log_membername_as_agent = 0;
 
+/*! \brief queues.conf [general] option */
+static int check_state_unknown = 0;
+
 enum queue_result {
 	QUEUE_UNKNOWN = 0,
 	QUEUE_TIMEOUT = 1,
@@ -1195,12 +1198,6 @@
 	int autofill;                       /*!< Ignore the head call status and ring an available agent */
 	
 	struct ao2_container *members;             /*!< Head of the list of members */
-	/*! 
-	 * \brief Number of members _logged in_
-	 * \note There will be members in the members container that are not logged
-	 *       in, so this can not simply be replaced with ao2_container_count(). 
-	 */
-	int membercount;
 	struct queue_ent *head;             /*!< Head of the list of callers */
 	AST_LIST_ENTRY(call_queue) list;    /*!< Next call queue */
 	AST_LIST_HEAD_NOLOCK(, penalty_rule) rules; /*!< The list of penalty rules to invoke */
@@ -1451,7 +1448,7 @@
 };
 
 /*! \brief set a member's status based on device state of that member's state_interface.
- *  
+ *
  * Lock interface list find sc, iterate through each queues queue_member list for member to
  * update state inside queues
 */
@@ -1630,21 +1627,24 @@
 static struct member *create_queue_member(const char *interface, const char *membername, int penalty, int paused, const char *state_interface)
 {
 	struct member *cur;
-	
+
 	if ((cur = ao2_alloc(sizeof(*cur), NULL))) {
 		cur->penalty = penalty;
 		cur->paused = paused;
 		ast_copy_string(cur->interface, interface, sizeof(cur->interface));
-		if (!ast_strlen_zero(state_interface))
+		if (!ast_strlen_zero(state_interface)) {
 			ast_copy_string(cur->state_interface, state_interface, sizeof(cur->state_interface));
-		else
+		} else {
 			ast_copy_string(cur->state_interface, interface, sizeof(cur->state_interface));
-		if (!ast_strlen_zero(membername))
+		}
+		if (!ast_strlen_zero(membername)) {
 			ast_copy_string(cur->membername, membername, sizeof(cur->membername));
-		else
+		} else {
 			ast_copy_string(cur->membername, interface, sizeof(cur->membername));
-		if (!strchr(cur->interface, '/'))
+		}
+		if (!strchr(cur->interface, '/')) {
 			ast_log(LOG_WARNING, "No location at interface '%s'\n", interface);
+		}
 		if (!strncmp(cur->state_interface, "hint:", 5)) {
 			char *tmp = ast_strdupa(cur->state_interface), *context = tmp;
 			char *exten = strsep(&context, "@") + 5;
@@ -1672,22 +1672,29 @@
 static int member_hash_fn(const void *obj, const int flags)
 {
 	const struct member *mem = obj;
-	const char *chname = strchr(mem->interface, '/');
+	const char *interface = (flags & OBJ_KEY) ? obj : mem->interface;
+	const char *chname = strchr(interface, '/');
 	int ret = 0, i;
-	if (!chname)
-		chname = mem->interface;
-	for (i = 0; i < 5 && chname[i]; i++)
+
+	if (!chname) {
+		chname = interface;
+	}
+	for (i = 0; i < 5 && chname[i]; i++) {
 		ret += compress_char(chname[i]) << (i * 6);
+	}
 	return ret;
 }
 
 static int member_cmp_fn(void *obj1, void *obj2, int flags)
 {
-	struct member *mem1 = obj1, *mem2 = obj2;
-	return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH | CMP_STOP;
-}
-
-/*! 
+	struct member *mem1 = obj1;
+	struct member *mem2 = obj2;
+	const char *interface = (flags & OBJ_KEY) ? obj2 : mem2->interface;
+
+	return strcasecmp(mem1->interface, interface) ? 0 : CMP_MATCH | CMP_STOP;
+}
+
+/*!
  * \brief Initialize Queue default values.
  * \note the queue's lock  must be held before executing this function
 */
@@ -1788,14 +1795,14 @@
 	}
 }
 
-/*! 
+/*!
  * \brief Change queue penalty by adding rule.
  *
- * Check rule for errors with time or fomatting, see if rule is relative to rest 
+ * Check rule for errors with time or fomatting, see if rule is relative to rest
  * of queue, iterate list of rules to find correct insertion point, insert and return.
  * \retval -1 on failure
- * \retval 0 on success 
- * \note Call this with the rule_lists locked 
+ * \retval 0 on success
+ * \note Call this with the rule_lists locked
 */
 static int insert_penaltychange(const char *list_name, const char *content, const int linenum)
 {
@@ -2149,8 +2156,9 @@
 
 	if (paused_str) {
 		paused = atoi(paused_str);
-		if (paused < 0)
+		if (paused < 0) {
 			paused = 0;
+		}
 	}
 
 	if ((config_val = ast_variable_retrieve(member_config, interface, "ignorebusy"))) {
@@ -2165,8 +2173,9 @@
 		if (!strcasecmp(m->rt_uniqueid, rt_uniqueid)) {
 			m->dead = 0;	/* Do not delete this one. */
 			ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid));
-			if (paused_str)
+			if (paused_str) {
 				m->paused = paused;
+			}
 			if (strcasecmp(state_interface, m->state_interface)) {
 				ast_copy_string(m->state_interface, state_interface, sizeof(m->state_interface));
 			}
@@ -2195,7 +2204,6 @@
 			ao2_link(q->members, m);
 			ao2_ref(m, -1);
 			m = NULL;
-			q->membercount++;
 		}
 	}
 }
@@ -2210,7 +2218,6 @@
 	while ((cur = ao2_iterator_next(&mem_iter))) {
 		if (all || !cur->dynamic) {
 			ao2_unlink(q->members, cur);
-			q->membercount--;
 		}
 		ao2_ref(cur, -1);
 	}
@@ -2252,15 +2259,15 @@
  * Check for statically defined queue first, check if deleted RT queue,
  * check for new RT queue, if queue vars are not defined init them with defaults.
  * reload RT queue vars, set RT queue members dead and reload them, return finished queue.
- * \retval the queue, 
+ * \retval the queue,
  * \retval NULL if it doesn't exist.
- * \note Should be called with the "queues" container locked. 
+ * \note Should be called with the "queues" container locked.
 */
 static struct call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config)
 {
 	struct ast_variable *v;
 	struct call_queue *q, tmpq = {
-		.name = queuename,	
+		.name = queuename,
 	};
 	struct member *m;
 	struct ao2_iterator mem_iter;
@@ -2283,10 +2290,10 @@
 				return q;
 			}
 		}
-	} else if (!member_config)
+	} else if (!member_config) {
 		/* Not found in the list, and it's not realtime ... */
 		return NULL;
-
+	}
 	/* Check if queue is defined in realtime. */
 	if (!queue_vars) {
 		/* Delete queue from in-core list if it has been deleted in realtime. */
@@ -2308,12 +2315,12 @@
 	/* Create a new queue if an in-core entry does not exist yet. */
 	if (!q) {
 		struct ast_variable *tmpvar = NULL;
-		if (!(q = alloc_queue(queuename)))
+		if (!(q = alloc_queue(queuename))) {
 			return NULL;
+		}
 		ao2_lock(q);
 		clear_queue(q);
 		q->realtime = 1;
-		q->membercount = 0;
 		/*Before we initialize the queue, we need to set the strategy, so that linear strategy
 		 * will allocate the members properly
 		 */
@@ -2329,8 +2336,9 @@
 			}
 		}
 		/* We traversed all variables and didn't find a strategy */
-		if (!tmpvar)
+		if (!tmpvar) {
 			q->strategy = QUEUE_STRATEGY_RINGALL;
+		}
 		queues_t_link(queues, q, "Add queue to container");
 	}
 	init_queue(q);		/* Ensure defaults for all parameters not set explicitly. */
@@ -2353,13 +2361,12 @@
 		queue_set_param(q, tmp_name, v->value, -1, 0);
 	}
 
-	/* Temporarily set realtime members dead so we can detect deleted ones. 
-	 * Also set the membercount correctly for realtime*/
+	/* Temporarily set realtime members dead so we can detect deleted ones. */
 	mem_iter = ao2_iterator_init(q->members, 0);
 	while ((m = ao2_iterator_next(&mem_iter))) {
-		q->membercount++;
-		if (m->realtime)
+		if (m->realtime) {
 			m->dead = 1;
+		}
 		ao2_ref(m, -1);
 	}
 	ao2_iterator_destroy(&mem_iter);
@@ -2378,7 +2385,6 @@
 				ast_queue_log(q->name, "REALTIME", m->membername, "REMOVEMEMBER", "%s", "");
 			}
 			ao2_unlink(q->members, m);
-			q->membercount--;
 		}
 		ao2_ref(m, -1);
 	}
@@ -2395,7 +2401,7 @@
 	struct ast_variable *queue_vars;
 	struct ast_config *member_config = NULL;
 	struct call_queue *q = NULL, tmpq = {
-		.name = queuename,	
+		.name = queuename,
 	};
 	int prev_weight = 0;
 
@@ -2498,7 +2504,6 @@
 				ast_queue_log(q->name, "REALTIME", m->membername, "REMOVEMEMBER", "%s", "");
 			}
 			ao2_unlink(q->members, m);
-			q->membercount--;
 		}
 		ao2_ref(m, -1);
 	}
@@ -2515,9 +2520,9 @@
 	int pos = 0;
 	int inserted = 0;
 
-	if (!(q = load_realtime_queue(queuename)))
+	if (!(q = load_realtime_queue(queuename))) {
 		return res;
-
+	}
 	ao2_lock(q);
 
 	/* This is our one */
@@ -2826,8 +2831,9 @@
 	struct penalty_rule *pr_iter;
 	int pos = 0;
 
-	if (!(q = qe->parent))
+	if (!(q = qe->parent)) {
 		return;
+	}
 	queue_t_ref(q, "Copy queue pointer from queue entry");
 	ao2_lock(q);
 
@@ -2870,7 +2876,7 @@
 		}
 	}
 
-	if (q->dead) {	
+	if (q->dead) {
 		/* It's dead and nobody is in it, so kill it */
 		queues_t_unlink(queues, q, "Queue is now dead; remove it from the container");
 	}
@@ -3101,12 +3107,12 @@
 	}
 
 	if (!qe->parent->ringinuse || !tmp->member->ignorebusy) {
-		if ((tmp->member->status == AST_DEVICE_UNKNOWN) || (tmp->member->status == AST_DEVICE_NOT_INUSE)) {
-			newstate = ast_parse_device_state(tmp->member->interface);
+		if (check_state_unknown && (tmp->member->status == AST_DEVICE_UNKNOWN)) {
+			newstate = ast_device_state(tmp->member->interface);
 			if (newstate != tmp->member->status) {
-				ast_log(LOG_ERROR, "Found a channel matching iterface %s while status was %i changed to %i\n",
-					tmp->member->interface, tmp->member->status, newstate);
-				update_status(qe->parent, tmp->member, newstate);
+				ast_log(LOG_WARNING, "Found a channel matching iterface %s while status was %s changed to %s\n",
+					tmp->member->interface, ast_devstate2str(tmp->member->status), ast_devstate2str(newstate));
+				ast_devstate_changed_literal(newstate, tmp->member->interface);
 			}
 		}
 		if ((tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) {
@@ -3141,7 +3147,7 @@
 		if (qe->chan->cdr) {
 			ast_cdr_busy(qe->chan->cdr);
 		}
-		tmp->stillgoing = 0;	
+		tmp->stillgoing = 0;
 
 		ao2_lock(qe->parent);
 		update_status(qe->parent, tmp->member, get_queue_member_status(tmp->member));
@@ -3486,8 +3492,10 @@
 				time_t idletime = time(&idletime)-mem->lastcall;
 				if ((mem->lastcall != 0) && (qe->parent->autopausedelay > idletime)) {
 					ao2_unlock(qe->parent);
+					ao2_ref(mem, -1);
 					return;
 				}
+				ao2_ref(mem, -1);
 			}
 			ao2_unlock(qe->parent);
 		}
@@ -4103,8 +4111,8 @@
 
 	struct member *mem;
 	struct call_queue *qtmp;
-	struct ao2_iterator queue_iter;	
-	
+	struct ao2_iterator queue_iter;
+
 	if (shared_lastcall) {
 		queue_iter = ao2_iterator_init(queues, 0);
 		while ((qtmp = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) {
@@ -4148,7 +4156,8 @@
 static int calc_metric(struct call_queue *q, struct member *mem, int pos, struct queue_ent *qe, struct callattempt *tmp)
 {
 	/* disregarding penalty on too few members? */
-	unsigned char usepenalty = (q->membercount <= q->penaltymemberslimit) ? 0 : 1;
+	int membercount = ao2_container_count(q->members);
+	unsigned char usepenalty = (membercount <= q->penaltymemberslimit) ? 0 : 1;
 
 	if (usepenalty) {
 		if ((qe->max_penalty && (mem->penalty > qe->max_penalty)) ||
@@ -4157,7 +4166,7 @@
 		}
 	} else {
 		ast_debug(1, "Disregarding penalty, %d members and %d in penaltymemberslimit.\n",
-			  q->membercount, q->penaltymemberslimit);
+			  membercount, q->penaltymemberslimit);
 	}
 
 	switch (q->strategy) {
@@ -4378,7 +4387,7 @@
 }
 
 /*! \brief A large function which calls members, updates statistics, and bridges the caller and a member
- * 
+ *
  * Here is the process of this function
  * 1. Process any options passed to the Queue() application. Options here mean the third argument to Queue()
  * 2. Iterate trough the members of the queue, creating a callattempt corresponding to each member. During this
@@ -4500,7 +4509,7 @@
 			if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY || qe->parent->strategy == QUEUE_STRATEGY_LINEAR || qe->parent->strategy == QUEUE_STRATEGY_RRORDERED)
 				(*tries)++;
 			else
-				*tries = qe->parent->membercount;
+				*tries = ao2_container_count(qe->parent->members);
 			*noption = 1;
 			break;
 		case 'i':
@@ -5210,9 +5219,9 @@
 	struct member *mem;
 	struct ao2_iterator mem_iter;
 
-	if (!q)
+	if (!q) {
 		return NULL;
-
+	}
 	mem_iter = ao2_iterator_init(q->members, 0);
 	while ((mem = ao2_iterator_next(&mem_iter))) {
 		if (!strcasecmp(interface, mem->interface)) {
@@ -5281,7 +5290,7 @@
 static int remove_from_queue(const char *queuename, const char *interface)
 {
 	struct call_queue *q, tmpq = {
-		.name = queuename,	
+		.name = queuename,
 	};
 	struct member *mem, tmpmem;
 	int res = RES_NOSUCHQUEUE;
@@ -5300,7 +5309,6 @@
 				queue_t_unref(q, "Interface wasn't dynamic, expiring temporary reference");
 				return RES_NOT_DYNAMIC;
 			}
-			q->membercount--;
 			manager_event(EVENT_FLAG_AGENT, "QueueMemberRemoved",
 				"Queue: %s\r\n"
 				"Location: %s\r\n"
@@ -5338,15 +5346,15 @@
 
 	/*! \note Ensure the appropriate realtime queue is loaded.  Note that this
 	 * short-circuits if the queue is already in memory. */
-	if (!(q = load_realtime_queue(queuename)))
+	if (!(q = load_realtime_queue(queuename))) {
 		return res;
+	}
 
 	ao2_lock(q);
 	if ((old_member = interface_exists(q, interface)) == NULL) {
 		if ((new_member = create_queue_member(interface, membername, penalty, paused, state_interface))) {
 			new_member->dynamic = 1;
 			ao2_link(q->members, new_member);
-			q->membercount++;
 			manager_event(EVENT_FLAG_AGENT, "QueueMemberAdded",
 				"Queue: %s\r\n"
 				"Location: %s\r\n"
@@ -5362,13 +5370,14 @@
 				"dynamic",
 				new_member->penalty, new_member->calls, (int) new_member->lastcall,
 				new_member->status, new_member->paused);
-			
+
 			ao2_ref(new_member, -1);
 			new_member = NULL;
 
-			if (dump)
+			if (dump) {
 				dump_queue_members(q);
-			
+			}
+
 			res = RES_OKAY;
 		} else {
 			res = RES_OUTOFMEMORY;
@@ -5409,14 +5418,14 @@
 				if (mem->realtime) {
 					failed = update_realtime_member_field(mem, q->name, "paused", paused ? "1" : "0");
 				}
-			
+
 				if (failed) {
 					ast_log(LOG_WARNING, "Failed %spausing realtime queue member %s:%s\n", (paused ? "" : "un"), q->name, interface);
 					ao2_ref(mem, -1);
 					ao2_unlock(q);
 					queue_t_unref(q, "Done with iterator");
 					continue;
-				}	
+				}
 				found++;
 				mem->paused = paused;
 
@@ -5424,7 +5433,7 @@
 					dump_queue_members(q);
 
 				ast_queue_log(q->name, "NONE", mem->membername, (paused ? "PAUSE" : "UNPAUSE"), "%s", S_OR(reason, ""));
-				
+
 				if (!ast_strlen_zero(reason)) {
 					manager_event(EVENT_FLAG_AGENT, "QueueMemberPaused",
 						"Queue: %s\r\n"
@@ -5444,13 +5453,13 @@
 				ao2_ref(mem, -1);
 			}
 		}
-		
+
 		if (!ast_strlen_zero(queuename) && !strcasecmp(queuename, q->name)) {
 			ao2_unlock(q);
 			queue_t_unref(q, "Done with iterator");
 			break;
 		}
-		
+
 		ao2_unlock(q);
 		queue_t_unref(q, "Done with iterator");
 	}
@@ -5500,22 +5509,22 @@
 		ast_log (LOG_ERROR, "Invalid queuename\n"); 
 	} else {
 		ast_log (LOG_ERROR, "Invalid interface\n");
-	}	
+	}
 
 	return RESULT_FAILURE;
 }
 
-/* \brief Gets members penalty. 
- * \return Return the members penalty or RESULT_FAILURE on error. 
+/* \brief Gets members penalty.
+ * \return Return the members penalty or RESULT_FAILURE on error.
 */
 static int get_member_penalty(char *queuename, char *interface)
 {
 	int foundqueue = 0, penalty;
 	struct call_queue *q, tmpq = {
-		.name = queuename,	
+		.name = queuename,
 	};
 	struct member *mem;
-	
+
 	if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Search for queue"))) {
 		foundqueue = 1;
 		ao2_lock(q);
@@ -5531,10 +5540,11 @@
 	}
 
 	/* some useful debuging */
-	if (foundqueue) 
+	if (foundqueue) {
 		ast_log (LOG_ERROR, "Invalid queuename\n");
-	else 
+	} else {
 		ast_log (LOG_ERROR, "Invalid interface\n");
+	}
 
 	return RESULT_FAILURE;
 }
@@ -5568,10 +5578,11 @@
 				.name = queue_name,
 			};
 			cur_queue = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Reload queue members");
-		}	
-
-		if (!cur_queue)
+		}
+
+		if (!cur_queue) {
 			cur_queue = load_realtime_queue(queue_name);
+		}
 
 		if (!cur_queue) {
 			/* If the queue no longer exists, remove it from the
@@ -5579,7 +5590,7 @@
 			ast_log(LOG_WARNING, "Error loading persistent queue: '%s': it does not exist\n", queue_name);
 			ast_db_del(pm_family, queue_name);
 			continue;
-		} 
+		}
 
 		if (ast_db_get(pm_family, queue_name, queue_data, PM_MAX_LEN)) {
 			queue_t_unref(cur_queue, "Expire reload reference");
@@ -5743,7 +5754,7 @@
 
 	switch (remove_from_queue(args.queuename, args.interface)) {
 	case RES_OKAY:
-		if (!mem || ast_strlen_zero(mem->membername) || !log_membername_as_agent) {
+		if (!mem || ast_strlen_zero(mem->membername)) {
 			ast_queue_log(args.queuename, chan->uniqueid, args.interface, "REMOVEMEMBER", "%s", "");
 		} else {
 			ast_queue_log(args.queuename, chan->uniqueid, mem->membername, "REMOVEMEMBER", "%s", "");
@@ -5767,6 +5778,10 @@
 		pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTDYNAMIC");
 		res = 0;
 		break;
+	}
+
+	if (mem) {
+		ao2_ref(mem, -1);
 	}
 
 	return res;
@@ -6123,7 +6138,7 @@
 		}
 
 		/* exit after 'timeout' cycle if 'n' option enabled */
-		if (noption && tries >= qe.parent->membercount) {
+		if (noption && tries >= ao2_container_count(qe.parent->members)) {
 			ast_verb(3, "Exiting on time-out cycle\n");
 			ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHTIMEOUT", "%d", qe.pos);
 			record_abandoned(&qe);
@@ -6214,7 +6229,7 @@
 {
 	int res = -1;
 	struct call_queue *q, tmpq = {
-		.name = data,	
+		.name = data,
 	};
 
 	char interfacevar[256] = "";
@@ -6340,16 +6355,19 @@
 			}
 			ao2_iterator_destroy(&mem_iter);
 		} else if (!strcasecmp(args.option, "count") || ast_strlen_zero(args.option)) {
-			count = q->membercount;
+			count = ao2_container_count(q->members);
 		} else if (!strcasecmp(args.option, "penalty") && !ast_strlen_zero(args.interface) &&
 			   ((m = interface_exists(q, args.interface)))) {
 			count = m->penalty;
+			ao2_ref(m, -1);
 		} else if (!strcasecmp(args.option, "paused") && !ast_strlen_zero(args.interface) &&
 			   ((m = interface_exists(q, args.interface)))) {
 			count = m->paused;
+			ao2_ref(m, -1);
 		} else if (!strcasecmp(args.option, "ignorebusy") && !ast_strlen_zero(args.interface) &&
 			   ((m = interface_exists(q, args.interface)))) {
 			count = m->ignorebusy;
+			ao2_ref(m, -1);
 		}
 		ao2_unlock(q);
 		queue_t_unref(q, "Done with temporary reference in QUEUE_MEMBER()");
@@ -6419,13 +6437,20 @@
 				}
 			} else {
 				ast_log(LOG_ERROR, "Invalid option, only penalty , paused or ignorebusy are valid\n");
+				ao2_ref(m, -1);
+				ao2_unlock(q);
+				ao2_ref(q, -1);
 				return -1;
 			}
+			ao2_ref(m, -1);
 		} else {
-			ast_log(LOG_ERROR, "Invalid interface or queue\n");
+			ao2_unlock(q);
+			ao2_ref(q, -1);
+			ast_log(LOG_ERROR, "Invalid interface for queue\n");
 			return -1;
 		}
 		ao2_unlock(q);
+		ao2_ref(q, -1);
         } else {
 		ast_log(LOG_ERROR, "Invalid queue\n");
 		return -1;
@@ -6469,8 +6494,9 @@
 		ao2_iterator_destroy(&mem_iter);
 		ao2_unlock(q);
 		queue_t_unref(q, "Done with temporary reference in QUEUE_MEMBER_COUNT");
-	} else
+	} else {
 		ast_log(LOG_WARNING, "queue %s was not found\n", data);
+	}
 
 	snprintf(buf, len, "%d", count);
 
@@ -6482,12 +6508,12 @@
 {
 	int count = 0;
 	struct call_queue *q, tmpq = {
-		.name = data,	
+		.name = data,
 	};
 	struct ast_variable *var = NULL;
 
 	buf[0] = '\0';
-	
+
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_ERROR, "QUEUE_WAITING_COUNT requires an argument: queuename\n");
 		return -1;
@@ -6500,7 +6526,7 @@
 		queue_t_unref(q, "Done with reference in QUEUE_WAITING_COUNT()");
 	} else if ((var = ast_load_realtime("queues", "name", data, SENTINEL))) {
 		/* if the queue is realtime but was not found in memory, this
-		 * means that the queue had been deleted from memory since it was 
+		 * means that the queue had been deleted from memory since it was
 		 * "dead." This means it has a 0 waiting count
 		 */
 		count = 0;
@@ -6517,7 +6543,7 @@
 static int queue_function_queuememberlist(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
 	struct call_queue *q, tmpq = {
-		.name = data,	
+		.name = data,
 	};
 	struct member *m;
 
@@ -6730,25 +6756,34 @@
 		queue_persistent_members = ast_true(general_val);
 	}
 	autofill_default = 0;
-	if ((general_val = ast_variable_retrieve(cfg, "general", "autofill")))
+	if ((general_val = ast_variable_retrieve(cfg, "general", "autofill"))) {
 		autofill_default = ast_true(general_val);
+	}
 	montype_default = 0;
 	if ((general_val = ast_variable_retrieve(cfg, "general", "monitor-type"))) {
 		if (!strcasecmp(general_val, "mixmonitor"))
 			montype_default = 1;
 	}
 	update_cdr = 0;
-	if ((general_val = ast_variable_retrieve(cfg, "general", "updatecdr")))
+	if ((general_val = ast_variable_retrieve(cfg, "general", "updatecdr"))) {
 		update_cdr = ast_true(general_val);
+	}
 	shared_lastcall = 0;
-	if ((general_val = ast_variable_retrieve(cfg, "general", "shared_lastcall")))
+	if ((general_val = ast_variable_retrieve(cfg, "general", "shared_lastcall"))) {
 		shared_lastcall = ast_true(general_val);
+	}
 	negative_penalty_invalid = 0;
-	if ((general_val = ast_variable_retrieve(cfg, "general", "negative_penalty_invalid")))
+	if ((general_val = ast_variable_retrieve(cfg, "general", "negative_penalty_invalid"))) {
 		negative_penalty_invalid = ast_true(general_val);
+	}
 	log_membername_as_agent = 0;

[... 8539 lines stripped ...]



More information about the asterisk-commits mailing list