[asterisk-commits] may: branch may/chan_ooh323_evo r344046 - in /team/may/chan_ooh323_evo: ./ bu...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 9 04:43:25 CST 2011


Author: may
Date: Wed Nov  9 04:43:14 2011
New Revision: 344046

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=344046
Log:
Multiple revisions 343534,343579,343581,343636,343684,343692-343693,343744,343790,343853,343905,343951,344005

........
  r343534 | mnicholson | 2011-11-07 22:42:04 +0400 (Mon, 07 Nov 2011) | 7 lines
  
  list all of the codecs associated with a particular format id for CLI command "core show codec"
  
  AST-699
  ........
  
  Merged revisions 343533 from http://svn.asterisk.org/svn/asterisk/branches/10
........
  r343579 | rmudgett | 2011-11-07 23:54:09 +0400 (Mon, 07 Nov 2011) | 27 lines
  
  Fix deadlock if peer is destroyed while sending MWI notice.
  
  A dialog cannot be destroyed by the ao2_callback dialog_needdestroy
  because of a deadlock between the dialogs container lock and the RWLOCK of
  the events subscription list.
  
  * Create dialogs_to_destroy container to hold dialogs that will be
  destroyed.
  
  * Ensure that the event subscription callback will never happen with an
  invalid peer pointer by making the event callback removal the first thing
  in the peer destructor callback.
  
  NOTE: This particular deadlock will not happen with Asterisk 10, but some
  of the changes still apply.
  
  (closes issue ASTERISK-18747)
  Reported by: Gregory Hinton Nietsky
  
  Review: https://reviewboard.asterisk.org/r/1564/
  ........
  
  Merged revisions 343577 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 343578 from http://svn.asterisk.org/svn/asterisk/branches/10
........
  r343581 | wdoekes | 2011-11-07 23:58:44 +0400 (Mon, 07 Nov 2011) | 14 lines
  
  Correct the default udptl port range.
  
  The udptl port range was defined as 4000-4999 in the udptl.conf.sample,
  as 4500-4599 if you didn't have a config and 4500-4999 if your config
  was broken. Default is now 4000-4999.
  
  (closes issue ASTERISK-16250)
  Reviewed by: Tilghman Lesher
  
  Review: https://reviewboard.asterisk.org/r/1565
  ........
  
  Merged revisions 343580 from http://svn.asterisk.org/svn/asterisk/branches/10
........
  r343636 | kmoore | 2011-11-08 00:35:58 +0400 (Tue, 08 Nov 2011) | 16 lines
  
  Prevent BLF subscriptions from causing deadlocks
  
  Fix a locking inversion in sip_send_mwi_to_peer that was causing deadlocks.
  This function now requires that both the peer and associated pvt be unlocked
  before it is called for cases where peer and peer->mwipvt form a circular
  reference.
  
  (closes issue ASTERISK-18663)
  Review: https://reviewboard.asterisk.org/r/1563/
  ........
  
  Merged revisions 343621 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 343635 from http://svn.asterisk.org/svn/asterisk/branches/10
........
  r343684 | rmudgett | 2011-11-08 01:29:01 +0400 (Tue, 08 Nov 2011) | 15 lines
  
  Fix __sip_subscribe_mwi_do() incorectly changing dialogs hash key callid.
  
  Changing an object value used as a container key requires removing the
  object from the container and reinserting it.
  
  * Created change_callid_pvt() to call instead of build_callid_pvt().  The
  change_callid_pvt() will correctly change the dialog callid so the ao2
  conainter can explicitly unlink it.
  ........
  
  Merged revisions 343637 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 343677 from http://svn.asterisk.org/svn/asterisk/branches/10
........
  r343692 | mnicholson | 2011-11-08 01:44:05 +0400 (Tue, 08 Nov 2011) | 10 lines
  
  respect case changes in peer names on sip reload
  
  ASTERISK-18669
  ........
  
  Merged revisions 343690 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 343691 from http://svn.asterisk.org/svn/asterisk/branches/10
........
  r343693 | lmadsen | 2011-11-08 01:58:14 +0400 (Tue, 08 Nov 2011) | 12 lines
  
  Allow built in variables to be used with dynamic weights.
  
  You can now use the built in variables , , and 
  within a dynamic weight. For example, this could be useful when you want
  to pass requested lookup number to the SHELL() function which could be
  used to execute a script to dynamically set the weight of the result.
  
  (Closes issue ASTERISK-13657)
  Reported by: Joel Vandal
  Tested by: Leif Madsen, Russell Bryant
  Patches:
       asterisk-1.6-dundi-varhead.patch uploaded by Joel Vandal (License #5374)
........
  r343744 | kmoore | 2011-11-08 02:37:51 +0400 (Tue, 08 Nov 2011) | 11 lines
  
  Make "sip show settings" CLI command get RPID flags from the right global page
  
  The "Trust RPID" and "Send RPID" entries in the "sip show settings" CLI command
  pulled the flags from the incorrect global flags page.  These are now read from
  sip global flags page 0.
  
  (closes issue AST-711)
  ........
  
  Merged revisions 343743 from http://svn.asterisk.org/svn/asterisk/branches/10
........
  r343790 | lmadsen | 2011-11-08 17:23:27 +0400 (Tue, 08 Nov 2011) | 8 lines
  
  Fix boo-boo in prep_tarball script.
  
  A hardcoded a branch number was in the prep_tarball which could not work. Changed
  it to the  variable.
  ........
  
  Merged revisions 343789 from http://svn.asterisk.org/svn/asterisk/branches/10
........
  r343853 | rmudgett | 2011-11-08 22:02:51 +0400 (Tue, 08 Nov 2011) | 20 lines
  
  Fixed reference to incorrect variable if unknown host configured crash.
  
  * Fixed a LOG_ERROR message referencing the config variable list v that
  had previously been processed and became NULL.
  
  * Added error return value set that was missing in an ast_append_ha()
  error return path.
  
  (closes issue ASTERISK-18743)
  Reported by: Michele
  Patches:
        issueA18743-fix_dynamic_exclude_static_bad_host_log.patch (license #5674) patch uploaded by Walter Doekes
  Tested by: Michele
  ........
  
  Merged revisions 343851 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 343852 from http://svn.asterisk.org/svn/asterisk/branches/10
........
  r343905 | dvossel | 2011-11-08 22:35:19 +0400 (Tue, 08 Nov 2011) | 17 lines
  
  Merged revisions 343900 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/10
  
  ........
    r343900 | dvossel | 2011-11-08 12:29:33 -0600 (Tue, 08 Nov 2011) | 11 lines
    
    Fixes regression caused by r343635
    
    There was a missing unlock for a function return that is only
    present in Asterisk 10 and Asterisk Trunk.
    
    (closes issue ASTERISK-18839)
    Reported by: Michael L. Young
    Patches:
        asterisk-18839-missing-lock-trunk-v2.diff (License #5026) patch uploaded by Michael L. Young
  ........
........
  r343951 | wdoekes | 2011-11-08 23:29:25 +0400 (Tue, 08 Nov 2011) | 15 lines
  
  Fix crash when dialplan remove include is called with too few arguments.
  
  "dialplan remove include x from y" crashed when the amount of arguments
  was less than 6.
  
  (closes issue ASTERISK-18762)
  Reported by: Andrey Solovyev
  Tested by: Andrey Solovyev
  ........
  
  Merged revisions 343936 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 343944 from http://svn.asterisk.org/svn/asterisk/branches/10
........
  r344005 | rmudgett | 2011-11-09 02:14:38 +0400 (Wed, 09 Nov 2011) | 17 lines
  
  Residual changes for Asterisk v10 branch from ASTERISK-18747.
  
  Residual changes for Asterisk v10 branch from ASTERISK-18747 after
  https://reviewboard.asterisk.org/r/1564/ commit and associated dialogs
  callid hash key change fix.
  
  * Make check_rtp_timeout() return CMP_MATCH if need to delete dialog from
  dialogs_rtpcheck.  This is an optimization to avoid an unneeded
  lock/unlock and object search when using ao2_unlink.
  
  * Prevent crash in check_rtp_timeout() if dialog->rtp is NULL.
  
  Review: https://reviewboard.asterisk.org/r/1557/
  ........
  
  Merged revisions 344004 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 343534,343579,343581,343636,343684,343692-343693,343744,343790,343853,343905,343951,344005 from http://svn.asterisk.org/svn/asterisk/trunk

Modified:
    team/may/chan_ooh323_evo/   (props changed)
    team/may/chan_ooh323_evo/CHANGES
    team/may/chan_ooh323_evo/UPGRADE.txt
    team/may/chan_ooh323_evo/build_tools/prep_tarball
    team/may/chan_ooh323_evo/channels/chan_sip.c
    team/may/chan_ooh323_evo/configs/dundi.conf.sample
    team/may/chan_ooh323_evo/main/acl.c
    team/may/chan_ooh323_evo/main/format.c
    team/may/chan_ooh323_evo/main/udptl.c
    team/may/chan_ooh323_evo/pbx/pbx_config.c
    team/may/chan_ooh323_evo/pbx/pbx_dundi.c

Propchange: team/may/chan_ooh323_evo/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Propchange: team/may/chan_ooh323_evo/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Nov  9 04:43:14 2011
@@ -1,1 +1,1 @@
-/trunk:1-343506
+/trunk:1-344045

Modified: team/may/chan_ooh323_evo/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/CHANGES?view=diff&rev=344046&r1=344045&r2=344046
==============================================================================
--- team/may/chan_ooh323_evo/CHANGES (original)
+++ team/may/chan_ooh323_evo/CHANGES Wed Nov  9 04:43:14 2011
@@ -49,6 +49,11 @@
 -----------
  * FAXOPT(faxdetect) will enable a generic fax detect framehook for dialplan
    control of faxdetect.
+
+DUNDi changes
+-------------
+ * Allow the built in variables ${NUMBER}, ${IPADDR} and ${SECRET} to be
+   used within the dynamic weight attribute when specifying a mapping.
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.8 to Asterisk 10 -------------------

Modified: team/may/chan_ooh323_evo/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/UPGRADE.txt?view=diff&rev=344046&r1=344045&r2=344046
==============================================================================
--- team/may/chan_ooh323_evo/UPGRADE.txt (original)
+++ team/may/chan_ooh323_evo/UPGRADE.txt Wed Nov  9 04:43:14 2011
@@ -116,5 +116,10 @@
    by default. It can be enabled using the 'storesipcause' option. This feature
    has a significant performance penalty.
 
+UDPTL:
+ - The default UDPTL port range in udptl.conf.sample differed from the defaults
+   in the source. If you didn't have a config file, you got 4500 to 4599. Now the
+   default is 4000 to 4999.
+
 ===========================================================
 ===========================================================

Modified: team/may/chan_ooh323_evo/build_tools/prep_tarball
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/build_tools/prep_tarball?view=diff&rev=344046&r1=344045&r2=344046
==============================================================================
--- team/may/chan_ooh323_evo/build_tools/prep_tarball (original)
+++ team/may/chan_ooh323_evo/build_tools/prep_tarball Wed Nov  9 04:43:14 2011
@@ -24,6 +24,6 @@
 echo "Extracting HTML Admin Guide"
 unzip Asterisk-Admin-Guide-$branch.html.zip
 mv AST/ Asterisk-Admin-Guide/
-mv Asterisk-Admin-Guide-1.8.pdf Asterisk-Admin-Guide.pdf
+mv Asterisk-Admin-Guide-$branch.pdf Asterisk-Admin-Guide.pdf
 rm -f Asterisk-Admin-Guide-$branch.html.zip
 echo "Documentation downloaded. Goodbye!"

Modified: team/may/chan_ooh323_evo/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/channels/chan_sip.c?view=diff&rev=344046&r1=344045&r2=344046
==============================================================================
--- team/may/chan_ooh323_evo/channels/chan_sip.c (original)
+++ team/may/chan_ooh323_evo/channels/chan_sip.c Wed Nov  9 04:43:14 2011
@@ -1078,21 +1078,24 @@
 	}
 }
 
-/*! \brief
+/*!
+ * \details
  * Here we implement the container for dialogs which are in the
  * dialog_needdestroy state to iterate only through the dialogs
  * unlink them instead of iterate through all dialogs
  */
 struct ao2_container *dialogs_needdestroy;
 
-/*! \brief
+/*!
+ * \details
  * Here we implement the container for dialogs which have rtp
  * traffic and rtptimeout, rtpholdtimeout or rtpkeepalive
  * set. We use this container instead the whole dialog list.
  */
 struct ao2_container *dialogs_rtpcheck;
 
-/*! \brief
+/*!
+ * \details
  * Here we implement the container for dialogs (sip_pvt), defining
  * generic wrapper functions to ease the transition from the current
  * implementation (a single linked list) to a different container.
@@ -1341,7 +1344,7 @@
 static struct sip_auth *find_realm_authentication(struct sip_auth_container *credentials, const char *realm);
 
 /*--- Misc functions */
-static void check_rtp_timeout(struct sip_pvt *dialog, time_t t);
+static int check_rtp_timeout(struct sip_pvt *dialog, time_t t);
 static int reload_config(enum channelreloadreason reason);
 static void add_diversion_header(struct sip_request *req, struct sip_pvt *pvt);
 static int expire_register(const void *data);
@@ -1514,6 +1517,7 @@
 static int create_addr(struct sip_pvt *dialog, const char *opeer, struct ast_sockaddr *addr, int newdialog, struct ast_sockaddr *remote_address);
 static char *generate_random_string(char *buf, size_t size);
 static void build_callid_pvt(struct sip_pvt *pvt);
+static void change_callid_pvt(struct sip_pvt *pvt, const char *callid);
 static void build_callid_registry(struct sip_registry *reg, const struct ast_sockaddr *ourip, const char *fromdomain);
 static void make_our_tag(char *tagbuf, size_t len);
 static int add_header(struct sip_request *req, const char *var, const char *value);
@@ -2947,15 +2951,13 @@
 	}
 }
 
- /*!
- * \brief Unlink a dialog from the dialogs_checkrtp container
+/*!
+ * \brief Unlink a dialog from the dialogs container, as well as any other places
+ * that it may be currently stored.
+ *
+ * \note A reference to the dialog must be held before calling this function, and this
+ * function does not release that reference.
  */
-static void *dialog_unlink_rtpcheck(struct sip_pvt *dialog)
-{
-	ao2_t_unlink(dialogs_rtpcheck, dialog, "unlinking dialog_rtpcheck via ao2_unlink");
-	return NULL;
-}
-
 void dialog_unlink_all(struct sip_pvt *dialog)
 {
 	struct sip_pkt *cp;
@@ -3069,11 +3071,11 @@
 	if (pvt->final_destruction_scheduled) {
 		return; /* This is already scheduled for final destruction, let the scheduler take care of it. */
 	}
-	if(pvt->needdestroy != 1) {
+	append_history(pvt, "NeedDestroy", "Setting needdestroy because %s", reason);
+	if (!pvt->needdestroy) {
+		pvt->needdestroy = 1;
 		ao2_t_link(dialogs_needdestroy, pvt, "link pvt into dialogs_needdestroy container");
 	}
-	append_history(pvt, "NeedDestroy", "Setting needdestroy because %s", reason);
-	pvt->needdestroy = 1;
 }
 
 /*! \brief Initialize the initital request packet in the pvt structure.
@@ -4589,9 +4591,18 @@
 static void sip_destroy_peer(struct sip_peer *peer)
 {
 	ast_debug(3, "Destroying SIP peer %s\n", peer->name);
-	if (peer->outboundproxy)
+
+	/*
+	 * Remove any mailbox event subscriptions for this peer before
+	 * we destroy anything.  An event subscription callback may be
+	 * happening right now.
+	 */
+	clear_peer_mailboxes(peer);
+
+	if (peer->outboundproxy) {
 		ao2_ref(peer->outboundproxy, -1);
-	peer->outboundproxy = NULL;
+		peer->outboundproxy = NULL;
+	}
 
 	/* Delete it, it needs to disappear */
 	if (peer->call) {
@@ -4625,7 +4636,6 @@
 	}
 	if (peer->dnsmgr)
 		ast_dnsmgr_release(peer->dnsmgr);
-	clear_peer_mailboxes(peer);
 
 	if (peer->socket.tcptls_session) {
 		ao2_ref(peer->socket.tcptls_session, -1);
@@ -5325,15 +5335,20 @@
 	if (!ast_strlen_zero(peer->fromdomain)) {
 		ast_string_field_set(dialog, fromdomain, peer->fromdomain);
 		if (!dialog->initreq.headers) {
-			char *c;
+			char *new_callid;
 			char *tmpcall = ast_strdupa(dialog->callid);
 			/* this sure looks to me like we are going to change the callid on this dialog!! */
-			c = strchr(tmpcall, '@');
-			if (c) {
-				*c = '\0';
-				ao2_t_unlink(dialogs, dialog, "About to change the callid -- remove the old name");
-				ast_string_field_build(dialog, callid, "%s@%s", tmpcall, peer->fromdomain);
-				ao2_t_link(dialogs, dialog, "New dialog callid -- inserted back into table");
+			new_callid = strchr(tmpcall, '@');
+			if (new_callid) {
+				int callid_size;
+
+				*new_callid = '\0';
+
+				/* Change the dialog callid. */
+				callid_size = strlen(tmpcall) + strlen(peer->fromdomain) + 2;
+				new_callid = alloca(callid_size);
+				snprintf(new_callid, callid_size, "%s@%s", tmpcall, peer->fromdomain);
+				change_callid_pvt(dialog, new_callid);
 			}
 		}
 	}
@@ -6247,7 +6262,6 @@
 		ast_debug(4, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 		ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER);	/* Really hang up next time */
-		p->needdestroy = 0;
 		p->owner->tech_pvt = dialog_unref(p->owner->tech_pvt, "unref p->owner->tech_pvt");
 		sip_pvt_lock(p);
 		p->owner = NULL;  /* Owner will be gone after we return, so take it away */
@@ -7498,15 +7512,68 @@
 	return buf;
 }
 
-/*! \brief Build SIP Call-ID value for a non-REGISTER transaction */
+/*!
+ * \brief Build SIP Call-ID value for a non-REGISTER transaction
+ *
+ * \note The passed in pvt must not be in a dialogs container
+ * since this function changes the hash key used by the
+ * container.
+ */
 static void build_callid_pvt(struct sip_pvt *pvt)
 {
 	char buf[33];
-
 	const char *host = S_OR(pvt->fromdomain, ast_sockaddr_stringify_remote(&pvt->ourip));
-	
+
 	ast_string_field_build(pvt, callid, "%s@%s", generate_random_string(buf, sizeof(buf)), host);
-
+}
+
+/*! \brief Unlink the given object from the container and return TRUE if it was in the container. */
+#define CONTAINER_UNLINK(container, obj, tag)								\
+	({																		\
+		int found = 0;														\
+		typeof((obj)) __removed_obj;										\
+		__removed_obj = ao2_t_callback((container),							\
+			OBJ_UNLINK | OBJ_POINTER, ao2_match_by_addr, (obj), (tag));		\
+		if (__removed_obj) {												\
+			ao2_ref(__removed_obj, -1);										\
+			found = 1;														\
+		}																	\
+		found;																\
+	})
+
+/*!
+ * \internal
+ * \brief Safely change the callid of the given SIP dialog.
+ *
+ * \param pvt SIP private structure to change callid
+ * \param callid Specified new callid to use.  NULL if generate new callid.
+ *
+ * \return Nothing
+ */
+static void change_callid_pvt(struct sip_pvt *pvt, const char *callid)
+{
+	int in_dialog_container;
+	int in_rtp_container;
+
+	ao2_lock(dialogs);
+	ao2_lock(dialogs_rtpcheck);
+	in_dialog_container = CONTAINER_UNLINK(dialogs, pvt,
+		"About to change the callid -- remove the old name");
+	in_rtp_container = CONTAINER_UNLINK(dialogs_rtpcheck, pvt,
+		"About to change the callid -- remove the old name");
+	if (callid) {
+		ast_string_field_set(pvt, callid, callid);
+	} else {
+		build_callid_pvt(pvt);
+	}
+	if (in_dialog_container) {
+		ao2_t_link(dialogs, pvt, "New dialog callid -- inserted back into table");
+	}
+	if (in_rtp_container) {
+		ao2_t_link(dialogs_rtpcheck, pvt, "New dialog callid -- inserted back into table");
+	}
+	ao2_unlock(dialogs_rtpcheck);
+	ao2_unlock(dialogs);
 }
 
 /*! \brief Build SIP Call-ID value for a REGISTER transaction */
@@ -11657,9 +11724,14 @@
 	/* Update lastrtprx when we send our SDP */
 	p->lastrtprx = p->lastrtptx = time(NULL); /* XXX why both ? */
 
-	/* we unlink this dialog and link again into the dialogs_rtpcheck container to doesnt add it twice */
+	/*
+	 * We unlink this dialog and link again into the
+	 * dialogs_rtpcheck container so its not in there twice.
+	 */
+	ao2_lock(dialogs_rtpcheck);
 	ao2_t_unlink(dialogs_rtpcheck, p, "unlink pvt into dialogs_rtpcheck container");
 	ao2_t_link(dialogs_rtpcheck, p, "link pvt into dialogs_rtpcheck container");
+	ao2_unlock(dialogs_rtpcheck);
 
 	ast_debug(3, "Done building SDP. Settling with this capability: %s\n", ast_getformatname_multiple(buf, SIPBUFSIZE, tmpcap));
 
@@ -12444,7 +12516,10 @@
 	ast_sip_ouraddrfor(&mwi->call->sa, &mwi->call->ourip, mwi->call);
 	build_contact(mwi->call);
 	build_via(mwi->call);
-	build_callid_pvt(mwi->call);
+
+	/* Change the dialog callid. */
+	change_callid_pvt(mwi->call, NULL);
+
 	ast_set_flag(&mwi->call->flags[0], SIP_OUTGOING);
 	
 	/* Associate the call with us */
@@ -14840,7 +14915,9 @@
 		}
 	}
 	if (!res) {
+		ao2_unlock(p);
 		sip_send_mwi_to_peer(peer, 0);
+		ao2_lock(p);
 		ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
 	}
 	if (res < 0) {
@@ -17017,42 +17094,45 @@
 	}
 }
 
-/*! \brief Check RTP Timeout on dialogs
+/*!
+ * \brief Check RTP Timeout on dialogs
+ *
  * \details This is used with ao2_callback to check rtptimeout
- * rtponholdtimeout and send rtpkeepalive packets
+ * rtponholdtimeout and send rtpkeepalive packets.
+ *
+ * \return CMP_MATCH for items to be unlinked from dialogs_rtpcheck.
  */
 static int dialog_checkrtp_cb(void *dialogobj, void *arg, int flags)
 {
 	struct sip_pvt *dialog = dialogobj;
 	time_t *t = arg;
+	int match_status;
 
 	if (sip_pvt_trylock(dialog)) {
 		return 0;
 	}
 
 	if (dialog->rtp || dialog->vrtp) {
-		check_rtp_timeout(dialog, *t);
+		match_status = check_rtp_timeout(dialog, *t);
 	} else {
-		/* Dialog has no active RTP or VRTP. unlink it from the checkrtp container */
-		dialog_unlink_rtpcheck(dialog);
+		/* Dialog has no active RTP or VRTP. unlink it from dialogs_rtpcheck. */
+		match_status = CMP_MATCH;
 	}
 	sip_pvt_unlock(dialog);
 
-	return 0;
+	return match_status;
 }
 
 /*!
  * \brief Match dialogs that need to be destroyed
  *
  * \details This is used with ao2_callback to unlink/delete all dialogs that
- * are marked needdestroy. It will return CMP_MATCH for candidates, and they
- * will be unlinked.
+ * are marked needdestroy.
  *
  * \todo Re-work this to improve efficiency.  Currently, this function is called
  * on _every_ dialog after processing _every_ incoming SIP/UDP packet, or
  * potentially even more often when the scheduler has entries to run.
  */
-
 static int dialog_needdestroy(void *dialogobj, void *arg, int flags)
 {
 	struct sip_pvt *dialog = dialogobj;
@@ -17062,7 +17142,6 @@
 		 * that we can wait for the next time around. */
 		return 0;
 	}
-
 
 	/* If we have sessions that needs to be destroyed, do it now */
 	/* Check if we have outstanding requests not responsed to or an active call
@@ -18122,8 +18201,8 @@
 	ast_cli(a->fd, "  SDP Owner Name:         %s\n", ast_strlen_zero(global_sdpowner) ? "-" : global_sdpowner);
 	ast_cli(a->fd, "  Reg. context:           %s\n", S_OR(sip_cfg.regcontext, "(not set)"));
 	ast_cli(a->fd, "  Regexten on Qualify:    %s\n", AST_CLI_YESNO(sip_cfg.regextenonqualify));
-	ast_cli(a->fd, "  Trust RPID:             %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[1], SIP_TRUSTRPID)));
-	ast_cli(a->fd, "  Send RPID:              %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[1], SIP_SENDRPID)));
+	ast_cli(a->fd, "  Trust RPID:             %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[0], SIP_TRUSTRPID)));
+	ast_cli(a->fd, "  Send RPID:              %s\n", AST_CLI_YESNO(ast_test_flag(&global_flags[0], SIP_SENDRPID)));
 	ast_cli(a->fd, "  Legacy userfield parse: %s\n", AST_CLI_YESNO(sip_cfg.legacy_useroption_parsing));
 	ast_cli(a->fd, "  Caller ID:              %s\n", default_callerid);
 	if ((default_fromdomainport) && (default_fromdomainport != STANDARD_SIP_PORT)) {
@@ -25010,7 +25089,9 @@
 
 		p->subscribed = MWI_NOTIFICATION;
 		if (ast_test_flag(&authpeer->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY)) {
+			ao2_unlock(p);
 			add_peer_mwi_subs(authpeer);
+			ao2_lock(p);
 		}
 		if (authpeer->mwipvt && authpeer->mwipvt != p) {	/* Destroy old PVT if this is a new one */
 			/* We only allow one subscription per peer */
@@ -25086,7 +25167,12 @@
 			ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
 			transmit_response(p, "200 OK", req);
 			if (p->relatedpeer) {	/* Send first notification */
-				sip_send_mwi_to_peer(p->relatedpeer, 0);
+				struct sip_peer *peer = p->relatedpeer;
+				sip_ref_peer(peer, "ensure a peer ref is held during MWI sending");
+				ao2_unlock(p);
+				sip_send_mwi_to_peer(peer, 0);
+				ao2_lock(p);
+				sip_unref_peer(peer, "release a peer ref now that MWI is sent");
 			}
 		} else if (p->subscribed != CALL_COMPLETION) {
 
@@ -25822,6 +25908,7 @@
 }
 
 /*! \brief Send message waiting indication to alert peer that they've got voicemail
+ *  \note Both peer and associated sip_pvt must be unlocked prior to calling this function
  *  \returns -1 on failure, 0 on success
  */
 static int sip_send_mwi_to_peer(struct sip_peer *peer, int cache_only)
@@ -25829,13 +25916,20 @@
 	/* Called with peerl lock, but releases it */
 	struct sip_pvt *p;
 	int newmsgs = 0, oldmsgs = 0;
+	const char *vmexten;
+
+	ao2_lock(peer);
+
+	vmexten = ast_strdupa(peer->vmexten);
 
 	if (ast_test_flag((&peer->flags[1]), SIP_PAGE2_SUBSCRIBEMWIONLY) && !peer->mwipvt) {
+		ao2_unlock(peer);
 		return -1;
 	}
 
 	/* Do we have an IP address? If not, skip this peer */
 	if (ast_sockaddr_isnull(&peer->addr) && ast_sockaddr_isnull(&peer->defaddr)) {
+		ao2_unlock(peer);
 		return -1;
 	}
 
@@ -25846,19 +25940,22 @@
 		peer_mailboxes_to_str(&mailbox_str, peer);
 		/* if there is no mailbox do nothing */
 		if (ast_strlen_zero(mailbox_str->str)) {
+			ao2_unlock(peer);
 			return -1;
 		}
+		ao2_unlock(peer);
 		ast_app_inboxcount(mailbox_str->str, &newmsgs, &oldmsgs);
-	}
-	ao2_lock(peer);
+		ao2_lock(peer);
+	}
 
 	if (peer->mwipvt) {
 		/* Base message on subscription */
-		p = dialog_ref(peer->mwipvt, "sip_send_mwi_to_peer: Setting dialog ptr p from peer->mwipvt-- should this be done?");
+		p = dialog_ref(peer->mwipvt, "sip_send_mwi_to_peer: Setting dialog ptr p from peer->mwipvt");
+		ao2_unlock(peer);
 	} else {
+		ao2_unlock(peer);
 		/* Build temporary dialog for this message */
 		if (!(p = sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL))) {
-			ao2_unlock(peer);
 			return -1;
 		}
 
@@ -25872,20 +25969,23 @@
 			dialog_unlink_all(p);
 			dialog_unref(p, "unref dialog p just created via sip_alloc");
 			/* sip_destroy(p); */
-			ao2_unlock(peer);
 			return -1;
 		}
 		/* Recalculate our side, and recalculate Call ID */
 		ast_sip_ouraddrfor(&p->sa, &p->ourip, p);
 		build_via(p);
-		ao2_t_unlink(dialogs, p, "About to change the callid -- remove the old name");
-		build_callid_pvt(p);
+
+		ao2_lock(peer);
 		if (!ast_strlen_zero(peer->mwi_from)) {
 			ast_string_field_set(p, mwi_from, peer->mwi_from);
 		} else if (!ast_strlen_zero(default_mwi_from)) {
 			ast_string_field_set(p, mwi_from, default_mwi_from);
 		}
-		ao2_t_link(dialogs, p, "Linking in under new name");
+		ao2_unlock(peer);
+
+		/* Change the dialog callid. */
+		change_callid_pvt(p, NULL);
+
 		/* Destroy this session after 32 secs */
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 	}
@@ -25897,40 +25997,49 @@
 	/* Send MWI */
 	ast_set_flag(&p->flags[0], SIP_OUTGOING);
 	/* the following will decrement the refcount on p as it finishes */
-	transmit_notify_with_mwi(p, newmsgs, oldmsgs, peer->vmexten);
+	transmit_notify_with_mwi(p, newmsgs, oldmsgs, vmexten);
 	sip_pvt_unlock(p);
 	dialog_unref(p, "unref dialog ptr p just before it goes out of scope at the end of sip_send_mwi_to_peer.");
-	ao2_unlock(peer);
+
 	return 0;
 }
 
-/*! \brief helper function for the monitoring thread -- seems to be called with the assumption that the dialog is locked */
-static void check_rtp_timeout(struct sip_pvt *dialog, time_t t)
+/*!
+ * \brief helper function for the monitoring thread -- seems to be called with the assumption that the dialog is locked
+ *
+ * \return CMP_MATCH for items to be unlinked from dialogs_rtpcheck.
+ */
+static int check_rtp_timeout(struct sip_pvt *dialog, time_t t)
 {
 	int timeout;
 	int hold_timeout;
 	int keepalive;
 
+	if (!dialog->rtp) {
+		/*
+		 * We have no RTP.  Since we don't do much with video RTP for
+		 * now, stop checking this dialog.
+		 */
+		return CMP_MATCH;
+	}
+
 	/* If we have no active owner, no need to check timers */
 	if (!dialog->owner) {
-		dialog_unlink_rtpcheck(dialog);
-		return;
-	}
+		return CMP_MATCH;
+	}
+
 	/* If the call is redirected outside Asterisk, no need to check timers */
-
 	if (!ast_sockaddr_isnull(&dialog->redirip)) {
-		dialog_unlink_rtpcheck(dialog);
-		return;
+		return CMP_MATCH;
 	}
 
 	/* If the call is involved in a T38 fax session do not check RTP timeout */
 	if (dialog->t38.state == T38_ENABLED) {
-		dialog_unlink_rtpcheck(dialog);
-		return;
+		return CMP_MATCH;
 	}
 	/* If the call is not in UP state return for later check. */
 	if (dialog->owner->_state != AST_STATE_UP) {
-		return;
+		return 0;
 	}
 
 	/* Store these values locally to avoid multiple function calls */
@@ -25940,8 +26049,7 @@
 
 	/* If we have no timers set, return now */
 	if (!keepalive && !timeout && !hold_timeout) {
-		dialog_unlink_rtpcheck(dialog);
-		return;
+		return CMP_MATCH;
 	}
 
 	/* Check AUDIO RTP keepalives */
@@ -25967,7 +26075,7 @@
 					 * Don't block, just try again later.
 					 * If there was no owner, the call is dead already.
 					 */
-					return;
+					return 0;
 				}
 				ast_log(LOG_NOTICE, "Disconnecting call '%s' for lack of RTP activity in %ld seconds\n",
 					dialog->owner->name, (long) (t - dialog->lastrtprx));
@@ -25984,10 +26092,12 @@
 					ast_rtp_instance_set_timeout(dialog->vrtp, 0);
 					ast_rtp_instance_set_hold_timeout(dialog->vrtp, 0);
 				}
-				dialog_unlink_rtpcheck(dialog); /* finally unlink the dialog from the checkrtp container */
-			}
-		}
-	}
+				/* finally unlink the dialog from dialogs_rtpcheck. */
+				return CMP_MATCH;
+			}
+		}
+	}
+	return 0;
 }
 
 /*! \brief The SIP monitoring thread
@@ -26031,15 +26141,20 @@
 
 		/* Check for dialogs needing to be killed */
 		t = time(NULL);
-		/* Check for dialogs with rtp and rtptimeout
-		 * All Dialogs which have rtp are in dialogs_rtpcheck container*/
-		ao2_t_callback(dialogs_rtpcheck, OBJ_NODATA | OBJ_MULTIPLE, dialog_checkrtp_cb, &t,
-				"callback to check rtptimeout and hangup calls if necessary");
-
-		/* Check for dialogs marked to be destroyed
-		 * All Dialogs which need Destroy are in dialogs_needdestroy container*/
-		ao2_t_callback(dialogs_needdestroy, OBJ_NODATA | OBJ_MULTIPLE, dialog_needdestroy, &t,
-				"callback to check rtptimeout and hangup calls if necessary");
+
+		/*
+		 * Check dialogs with rtp and rtptimeout.
+		 * All dialogs which have rtp are in dialogs_rtpcheck.
+		 */
+		ao2_t_callback(dialogs_rtpcheck, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE,
+			dialog_checkrtp_cb, &t,
+			"callback to check rtptimeout and hangup calls if necessary");
+		/*
+		 * Check dialogs marked to be destroyed.
+		 * All dialogs with needdestroy set are in dialogs_needdestroy.
+		 */
+		ao2_t_callback(dialogs_needdestroy, OBJ_NODATA | OBJ_MULTIPLE, dialog_needdestroy,
+			NULL, "callback to check dialogs which need to be destroyed");
 
 		/* XXX TODO The scheduler usage in this module does not have sufficient
 		 * synchronization being done between running the scheduler and places
@@ -26516,9 +26631,9 @@
 	/* Recalculate our side, and recalculate Call ID */
 	ast_sip_ouraddrfor(&p->sa, &p->ourip, p);
 	build_via(p);
-	ao2_t_unlink(dialogs, p, "About to change the callid -- remove the old name");
-	build_callid_pvt(p);
-	ao2_t_link(dialogs, p, "Linking in under new name");
+
+	/* Change the dialog callid. */
+	change_callid_pvt(p, NULL);
 
 	AST_SCHED_DEL_UNREF(sched, peer->pokeexpire,
 			sip_unref_peer(peer, "removing poke peer ref"));
@@ -26815,9 +26930,9 @@
 	/* Recalculate our side, and recalculate Call ID */
 	ast_sip_ouraddrfor(&p->sa, &p->ourip, p);
 	build_via(p);
-	ao2_t_unlink(dialogs, p, "About to change the callid -- remove the old name");
-	build_callid_pvt(p);
-	ao2_t_link(dialogs, p, "Linking in under new name");
+
+	/* Change the dialog callid. */
+	change_callid_pvt(p, NULL);
 
 	/* We have an extension to call, don't use the full contact here */
 	/* This to enable dialing registered peers with extension dialling,
@@ -27493,8 +27608,9 @@
 		set_peer_defaults(peer);	/* Set peer defaults */
 		peer->type = 0;
 	}
-	if (!found && name)
-		ast_copy_string(peer->name, name, sizeof(peer->name));
+
+	/* in case the case of the peer name has changed, update the name */
+	ast_copy_string(peer->name, name, sizeof(peer->name));
 
 	/* If we have channel variables, remove them (reload) */
 	if (peer->chanvars) {
@@ -28021,11 +28137,11 @@
 		ast_string_field_set(peer, tohost, srvlookup);
 
 		if (global_dynamic_exclude_static) {
-			int err = 0;
+			int ha_error = 0;
 			sip_cfg.contact_ha = ast_append_ha("deny", ast_sockaddr_stringify_addr(&peer->addr), 
-							sip_cfg.contact_ha, &err);
-			if (err) {
-				ast_log(LOG_ERROR, "Bad ACL entry in configuration line %d : %s\n", v->lineno, v->value);
+							sip_cfg.contact_ha, &ha_error);
+			if (ha_error) {
+				ast_log(LOG_ERROR, "Bad or unresolved host/IP entry in configuration for peer %s, cannot add to contact ACL\n", peer->name);
 			}
 		}
 	} else if (peer->dnsmgr && !peer->host_dynamic) {
@@ -30498,7 +30614,7 @@
 	peers = ao2_t_container_alloc(HASH_PEER_SIZE, peer_hash_cb, peer_cmp_cb, "allocate peers");
 	peers_by_ip = ao2_t_container_alloc(HASH_PEER_SIZE, peer_iphash_cb, peer_ipcmp_cb, "allocate peers_by_ip");
 	dialogs = ao2_t_container_alloc(HASH_DIALOG_SIZE, dialog_hash_cb, dialog_cmp_cb, "allocate dialogs");
-	dialogs_needdestroy = ao2_t_container_alloc(HASH_DIALOG_SIZE, dialog_hash_cb, dialog_cmp_cb, "allocate dialogs_needdestroy");
+	dialogs_needdestroy = ao2_t_container_alloc(1, NULL, NULL, "allocate dialogs_needdestroy");
 	dialogs_rtpcheck = ao2_t_container_alloc(HASH_DIALOG_SIZE, dialog_hash_cb, dialog_cmp_cb, "allocate dialogs for rtpchecks");
 	threadt = ao2_t_container_alloc(HASH_DIALOG_SIZE, threadt_hash_cb, threadt_cmp_cb, "allocate threadt table");
 	if (!peers || !peers_by_ip || !dialogs || !dialogs_needdestroy || !dialogs_rtpcheck
@@ -30772,8 +30888,8 @@
 	ao2_t_ref(peers, -1, "unref the peers table");
 	ao2_t_ref(peers_by_ip, -1, "unref the peers_by_ip table");
 	ao2_t_ref(dialogs, -1, "unref the dialogs table");
-	ao2_t_ref(dialogs_needdestroy, -1, "unref the dialogs table");
-	ao2_t_ref(dialogs_rtpcheck, -1, "unref the dialogs table");
+	ao2_t_ref(dialogs_needdestroy, -1, "unref dialogs_needdestroy");
+	ao2_t_ref(dialogs_rtpcheck, -1, "unref dialogs_rtpcheck");
 	ao2_t_ref(threadt, -1, "unref the thread table");
 	ao2_t_ref(sip_monitor_instances, -1, "unref the sip_monitor_instances table");
 

Modified: team/may/chan_ooh323_evo/configs/dundi.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/configs/dundi.conf.sample?view=diff&rev=344046&r1=344045&r2=344046
==============================================================================
--- team/may/chan_ooh323_evo/configs/dundi.conf.sample (original)
+++ team/may/chan_ooh323_evo/configs/dundi.conf.sample Wed Nov  9 04:43:14 2011
@@ -143,6 +143,10 @@
 ;    in a response shouuld be.
 ;testmap3 => context3,${SHELL(echo 123)},IAX2,guest at peer3/${NUMBER}
 ;
+; The built in variables ${SECRET}, ${IPADDR} and ${NUMBER} can also be
+; passed to the weight. For example, you could pass the ${NUMBER} value
+; to your SHELL() script and use that to dynamically return a weight.
+;
 ; Note than when using a global variable or dialplan function to set the
 ; weight for a mapping, that response caching should be disabled if you
 ; plan for these values to change frequently at all.  If the results are

Modified: team/may/chan_ooh323_evo/main/acl.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/main/acl.c?view=diff&rev=344046&r1=344045&r2=344046
==============================================================================
--- team/may/chan_ooh323_evo/main/acl.c (original)
+++ team/may/chan_ooh323_evo/main/acl.c Wed Nov  9 04:43:14 2011
@@ -408,6 +408,9 @@
 	}
 
 	if (!(ha = ast_calloc(1, sizeof(*ha)))) {
+		if (error) {
+			*error = 1;
+		}
 		return ret;
 	}
 

Modified: team/may/chan_ooh323_evo/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/main/format.c?view=diff&rev=344046&r1=344045&r2=344046
==============================================================================
--- team/may/chan_ooh323_evo/main/format.c (original)
+++ team/may/chan_ooh323_evo/main/format.c Wed Nov  9 04:43:14 2011
@@ -860,7 +860,6 @@
 		if (f_list[x].format.id == format_id) {
 			found = 1;
 			ast_cli(a->fd, "%11u %s\n", (unsigned int) format_id, f_list[x].desc);
-			break;
 		}
 	}
 

Modified: team/may/chan_ooh323_evo/main/udptl.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/main/udptl.c?view=diff&rev=344046&r1=344045&r2=344046
==============================================================================
--- team/may/chan_ooh323_evo/main/udptl.c (original)
+++ team/may/chan_ooh323_evo/main/udptl.c Wed Nov  9 04:43:14 2011
@@ -79,8 +79,11 @@
 
 #define LOG_TAG(u) S_OR(u->tag, "no tag")
 
-static int udptlstart = 4500;
-static int udptlend = 4599;
+#define DEFAULT_UDPTLSTART 4000
+#define DEFAULT_UDPTLEND 4999
+
+static int udptlstart = DEFAULT_UDPTLSTART;
+static int udptlend = DEFAULT_UDPTLEND;
 static int udptldebug;	                    /*!< Are we debugging? */
 static struct ast_sockaddr udptldebugaddr;   /*!< Debug packets to/from this host */
 #ifdef SO_NO_CHECK
@@ -1315,8 +1318,8 @@
 		return;
 	}
 
-	udptlstart = 4500;
-	udptlend = 4999;
+	udptlstart = DEFAULT_UDPTLSTART;
+	udptlend = DEFAULT_UDPTLEND;
 	udptlfecentries = 0;
 	udptlfecspan = 0;
 	use_even_ports = 0;
@@ -1388,18 +1391,18 @@
 		}
 		ast_config_destroy(cfg);
 	}
-	if (udptlstart >= udptlend) {
-		ast_log(LOG_WARNING, "Unreasonable values for UDPTL start/end ports; defaulting to 4500-4999.\n");
-		udptlstart = 4500;
-		udptlend = 4999;
-	}
 	if (use_even_ports && (udptlstart & 1)) {
 		++udptlstart;
 		ast_log(LOG_NOTICE, "Odd numbered udptlstart specified but use_even_ports enabled. udptlstart is now %d\n", udptlstart);
 	}
+	if (udptlstart > udptlend) {
+		ast_log(LOG_WARNING, "Unreasonable values for UDPTL start/end ports; defaulting to %d-%d.\n", DEFAULT_UDPTLSTART, DEFAULT_UDPTLEND);
+		udptlstart = DEFAULT_UDPTLSTART;
+		udptlend = DEFAULT_UDPTLEND;
+	}
 	if (use_even_ports && (udptlend & 1)) {
 		--udptlend;
-		ast_log(LOG_NOTICE, "Odd numbered udptlend specified but use_event_ports enabled. udptlend is now %d\n", udptlend);
+		ast_log(LOG_NOTICE, "Odd numbered udptlend specified but use_even_ports enabled. udptlend is now %d\n", udptlend);
 	}
 	ast_verb(2, "UDPTL allocating from port range %d -> %d\n", udptlstart, udptlend);
 }

Modified: team/may/chan_ooh323_evo/pbx/pbx_config.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/pbx/pbx_config.c?view=diff&rev=344046&r1=344045&r2=344046
==============================================================================
--- team/may/chan_ooh323_evo/pbx/pbx_config.c (original)
+++ team/may/chan_ooh323_evo/pbx/pbx_config.c Wed Nov  9 04:43:14 2011
@@ -87,7 +87,7 @@
 		return complete_dialplan_remove_include(a);
 	}
 
-	if (strcmp(a->argv[4], "from"))
+	if (a->argc != 6 || strcmp(a->argv[4], "from"))
 		return CLI_SHOWUSAGE;
 
 	if (!ast_context_remove_include(a->argv[5], a->argv[3], registrar)) {

Modified: team/may/chan_ooh323_evo/pbx/pbx_dundi.c
URL: http://svnview.digium.com/svn/asterisk/team/may/chan_ooh323_evo/pbx/pbx_dundi.c?view=diff&rev=344046&r1=344045&r2=344046
==============================================================================
--- team/may/chan_ooh323_evo/pbx/pbx_dundi.c (original)
+++ team/may/chan_ooh323_evo/pbx/pbx_dundi.c Wed Nov  9 04:43:14 2011
@@ -545,13 +545,18 @@
 	char fluffy[0];
 };
 

[... 50 lines stripped ...]



More information about the asterisk-commits mailing list