[asterisk-commits] qwell: branch qwell/fun_with_transports r387935 - in /team/qwell/fun_with_tra...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 8 09:15:58 CDT 2013


Author: qwell
Date: Wed May  8 09:15:51 2013
New Revision: 387935

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387935
Log:
Multiple revisions 387482,387519,387545,387594,387630,387633,387662,387690,387738,387740-387741,387802-387803,387824-387825,387885,387932

........
  r387482 | rmudgett | 2013-05-02 14:06:53 -0500 (Thu, 02 May 2013) | 1 line
  
  Remove the ABI compatability ast_channel_alloc().  It is no longer needed.
........
  r387519 | mjordan | 2013-05-02 15:59:20 -0500 (Thu, 02 May 2013) | 7 lines
  
  Migrate AMI VarSet events raised by GoSub local variables
  
  This patch moves VarSet events for local variables raised by GoSub
  over to Stasis-Core. It also tweaks up the post-processing documentation
  scripts to not combine parameters if both parameters are already documented.
  
  (issue ASTERISK-21462)
........
  r387545 | file | 2013-05-03 06:35:14 -0500 (Fri, 03 May 2013) | 4 lines
  
  Use the configured formats for Gulp sessions if there are no joint formats between requested formats and configured formats.
  
  (closes issue ASTERISK-21756)
........
  r387594 | jrose | 2013-05-03 13:03:26 -0500 (Fri, 03 May 2013) | 5 lines
  
  Stasis: Convert network change events into network change stasis messages
  
  (issue ASTERISK-21103)
  Review: https://reviewboard.asterisk.org/r/2490/
........
  r387630 | mjordan | 2013-05-04 10:24:31 -0500 (Sat, 04 May 2013) | 8 lines
  
  Migrate SHARED's use of the VarSet AMI event to Stasis-Core
  
  This patch removes the direct call to AMI from the SHARED function
  and instead call Stasis-Core. Stasis-Core delivers the notification
  that a shared variable has changed on a channel to all interested
  consumers.
  
  (issue ASTERISK-21462)
........
  r387633 | mjordan | 2013-05-04 11:00:46 -0500 (Sat, 04 May 2013) | 7 lines
  
  Clean up documentation; prevent ref leak on exit
  
  This patch:
   * Cleans up some doxygen
   * Prevents leaking the system level Stasis topics and messages
     on exit (users of valgrind will be happier)
........
  r387662 | file | 2013-05-06 08:04:08 -0500 (Mon, 06 May 2013) | 14 lines
  
  Add support for observers and JSON objectset creation to sorcery.
  
  This change adds the ability for modules to add themselves as observers
  to sorcery object types. Observers can be notified when objects are
  created, updated, or deleted as well as when the object type is loaded or
  reloaded. Observer notifications are done using a thread pool in a serialized
  fashion so the caller of the sorcery API calls is minimally impacted.
  
  This also adds the ability to create JSON changesets of a sorcery object.
  
  Tests are also present to confirm all of the above functionality.
  
  Review: https://reviewboard.asterisk.org/r/2477/
........
  r387690 | russell | 2013-05-06 10:58:32 -0500 (Mon, 06 May 2013) | 23 lines
  
  Make SLA reload more paranoid.
  
  Reload support was originally not included for SLA.  It was added later,
  but in a fairly non-traditional way.  It basically sets a flag
  indicating that a reload is pending, and then waits for a time where it
  thinks everything SLA related is idle and unused, and *then* executes
  the reload.  It does this because the reload process is destructive.  It
  starts by throwing everything away and starting over.
  
  There are a number of problems with this approach.  One of them is that
  the check to see if anything in use was incomplete.  This patch makes it
  more complete and thus less likely for a crash to occur during reload
  processing.  However, this approach still has problems so some much more
  significant reworking of this code will need to come in as a next step.
  
  Patch credit and testing by CoreDial, LLC.
  ........
  
  Merged revisions 387688 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 387689 from http://svn.asterisk.org/svn/asterisk/branches/11
........
  r387738 | qwell | 2013-05-06 12:01:41 -0500 (Mon, 06 May 2013) | 1 line
  
  Fix building with LOW_MEMORY defined.
........
  r387740 | rmudgett | 2013-05-06 12:09:50 -0500 (Mon, 06 May 2013) | 2 lines
  
  Make a log NOTICE more explicit that the event comes from DAHDI and not PRI.
........
  r387741 | rmudgett | 2013-05-06 12:15:20 -0500 (Mon, 06 May 2013) | 1 line
  
  Update ao2_destructor_fn doxygen.
........
  r387802 | qwell | 2013-05-07 12:53:50 -0500 (Tue, 07 May 2013) | 1 line
  
  Fix build breakage, from LOW_MEMORY fix.
........
  r387803 | dlee | 2013-05-07 13:12:26 -0500 (Tue, 07 May 2013) | 1 line
  
  Better explained the depths of reference stealing.
........
  r387824 | dlee | 2013-05-07 13:30:55 -0500 (Tue, 07 May 2013) | 7 lines
  
  Minor fixups to Doxygen comments.
  
  The \example tags marks an entire file as an example, not a code snippet.
  ........
  
  Merged revisions 387823 from http://svn.asterisk.org/svn/asterisk/branches/11
........
  r387825 | dlee | 2013-05-07 13:32:34 -0500 (Tue, 07 May 2013) | 4 lines
  
  Fixed up \example marker in lock.h Doxygen comment.
  
  The \example tags marks an entire file as an example, not a code snippet.
........
  r387885 | alecdavis | 2013-05-08 02:21:09 -0500 (Wed, 08 May 2013) | 25 lines
  
  chan_sip: NOTIFYs for BLF start queuing up and fail to be sent out after retries fail
  
  RFC6665 4.2.2: ... after a failed NOTIFY transaction remove the subscription
  
  The problem is that the State Notify requests rely on the 200OK reponse for pacing control
  and to not confuse the notify susbsystem.
  The issue is, the pendinginvite isn't cleared if a response isn't received,
  thus further notify's are never sent.
  
  The solution, follow RFC 6665 4.2.2.2's 'SHOULD' and remove the subscription after failure.
    
  (closes issue ASTERISK-21677)
  
  Reported by: alecdavis
  Tested by: alecdavis
  alecdavis (license 585)
  
  Review https://reviewboard.asterisk.org/r/2475/
  ........
  
  Merged revisions 387875 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 387880 from http://svn.asterisk.org/svn/asterisk/branches/11
........
  r387932 | dlee | 2013-05-08 08:39:08 -0500 (Wed, 08 May 2013) | 32 lines
  
  Initial support for endpoints.
  
  An endpoint is an external device/system that may offer/accept
  channels to/from Asterisk. While this is a very useful concept for end
  users, it is surprisingly not a core concept within Asterisk itself.
  
  This patch defines ast_endpoint as a separate object, which channel
  drivers may use to expose their concept of an endpoint. As the channel
  driver creates channels, it can use ast_endpoint_add_channel() to
  associate channels to the endpoint. This updated the endpoint
  appropriately, and forwards all of the channel's events to the
  endpoint's topic.
  
  In order to avoid excessive locking on the endpoint object itself, the
  mutable state is not accessible via getters. Instead, you can create a
  snapshot using ast_endpoint_snapshot_create() to get a consistent
  snapshot of the internal state.
  
  This patch also includes a set of topics and messages associated with
  endpoints, and implementations of the endpoint-related RESTful
  API. chan_sip was updated to create endpoints with SIP peers, but the
  state of the endpoints is not updated with the state of the peer.
  
  Along for the ride in this patch is a Stasis test API. This is a
  stasis_message_sink object, which can be subscribed to a Stasis
  topic. It has functions for blocking while waiting for conditions in
  the message sink to be fulfilled.
  
  (closes issue ASTERISK-21421)
  Review: https://reviewboard.asterisk.org/r/2492/
........

Merged revisions 387482,387519,387545,387594,387630,387633,387662,387690,387738,387740-387741,387802-387803,387824-387825,387885,387932 from http://svn.asterisk.org/svn/asterisk/trunk

Added:
    team/qwell/fun_with_transports/include/asterisk/endpoints.h
      - copied unchanged from r387932, trunk/include/asterisk/endpoints.h
    team/qwell/fun_with_transports/include/asterisk/stasis_endpoints.h
      - copied unchanged from r387932, trunk/include/asterisk/stasis_endpoints.h
    team/qwell/fun_with_transports/include/asterisk/stasis_test.h
      - copied unchanged from r387932, trunk/include/asterisk/stasis_test.h
    team/qwell/fun_with_transports/main/endpoints.c
      - copied unchanged from r387932, trunk/main/endpoints.c
    team/qwell/fun_with_transports/main/stasis_endpoints.c
      - copied unchanged from r387932, trunk/main/stasis_endpoints.c
    team/qwell/fun_with_transports/res/res_stasis_test.c
      - copied unchanged from r387932, trunk/res/res_stasis_test.c
    team/qwell/fun_with_transports/res/res_stasis_test.exports.in
      - copied unchanged from r387932, trunk/res/res_stasis_test.exports.in
    team/qwell/fun_with_transports/tests/test_endpoints.c
      - copied unchanged from r387932, trunk/tests/test_endpoints.c
    team/qwell/fun_with_transports/tests/test_stasis_endpoints.c
      - copied unchanged from r387932, trunk/tests/test_stasis_endpoints.c
Modified:
    team/qwell/fun_with_transports/   (props changed)
    team/qwell/fun_with_transports/apps/app_meetme.c
    team/qwell/fun_with_transports/apps/app_stack.c
    team/qwell/fun_with_transports/build_tools/post_process_documentation.py
    team/qwell/fun_with_transports/channels/chan_dahdi.c
    team/qwell/fun_with_transports/channels/chan_gulp.c
    team/qwell/fun_with_transports/channels/chan_iax2.c
    team/qwell/fun_with_transports/channels/chan_sip.c
    team/qwell/fun_with_transports/channels/sip/include/sip.h
    team/qwell/fun_with_transports/funcs/func_global.c
    team/qwell/fun_with_transports/include/asterisk.h
    team/qwell/fun_with_transports/include/asterisk/astobj2.h
    team/qwell/fun_with_transports/include/asterisk/json.h
    team/qwell/fun_with_transports/include/asterisk/lock.h
    team/qwell/fun_with_transports/include/asterisk/sorcery.h
    team/qwell/fun_with_transports/include/asterisk/stasis.h
    team/qwell/fun_with_transports/main/asterisk.c
    team/qwell/fun_with_transports/main/astobj2.c
    team/qwell/fun_with_transports/main/channel_internal_api.c
    team/qwell/fun_with_transports/main/event.c
    team/qwell/fun_with_transports/main/manager.c
    team/qwell/fun_with_transports/main/sorcery.c
    team/qwell/fun_with_transports/main/stasis_cache.c
    team/qwell/fun_with_transports/res/res_config_pgsql.c
    team/qwell/fun_with_transports/res/res_sip_sdp_rtp.c
    team/qwell/fun_with_transports/res/res_sorcery_astdb.c
    team/qwell/fun_with_transports/res/res_stasis_http_endpoints.c
    team/qwell/fun_with_transports/res/res_stun_monitor.c
    team/qwell/fun_with_transports/res/stasis_http/resource_endpoints.c
    team/qwell/fun_with_transports/res/stasis_http/resource_endpoints.h
    team/qwell/fun_with_transports/rest-api/api-docs/endpoints.json
    team/qwell/fun_with_transports/tests/test_sorcery.c

Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed May  8 09:15:51 2013
@@ -1,1 +1,1 @@
-/trunk:1-387426
+/trunk:1-387934

Modified: team/qwell/fun_with_transports/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/apps/app_meetme.c?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/apps/app_meetme.c (original)
+++ team/qwell/fun_with_transports/apps/app_meetme.c Wed May  8 09:15:51 2013
@@ -6447,8 +6447,8 @@
 	struct sla_station *station;
 	struct sla_trunk *trunk;
 
-	if (!AST_LIST_EMPTY(&sla.event_q) || !AST_LIST_EMPTY(&sla.ringing_trunks) 
-		|| !AST_LIST_EMPTY(&sla.ringing_stations)) {
+	if (!AST_LIST_EMPTY(&sla.event_q) || !AST_LIST_EMPTY(&sla.ringing_trunks)
+		|| !AST_LIST_EMPTY(&sla.ringing_stations) || !AST_LIST_EMPTY(&sla.failed_stations)) {
 		return;
 	}
 
@@ -6464,8 +6464,9 @@
 
 	AST_RWLIST_RDLOCK(&sla_trunks);
 	AST_RWLIST_TRAVERSE(&sla_trunks, trunk, entry) {
-		if (trunk->ref_count)
+		if (trunk->ref_count || trunk->chan || trunk->active_stations || trunk->hold_stations) {
 			break;
+		}
 	}
 	AST_RWLIST_UNLOCK(&sla_trunks);
 	if (trunk) {
@@ -6718,7 +6719,7 @@
 		return 0;
 	}
 
-	AST_RWLIST_RDLOCK(&sla_stations);
+	AST_RWLIST_WRLOCK(&sla_stations);
 	station = sla_find_station(station_name);
 	if (station)
 		ast_atomic_fetchadd_int((int *) &station->ref_count, 1);
@@ -6930,7 +6931,7 @@
 		}
 	}
 
-	AST_RWLIST_RDLOCK(&sla_trunks);
+	AST_RWLIST_WRLOCK(&sla_trunks);
 	trunk = sla_find_trunk(args.trunk_name);
 	if (trunk)
 		ast_atomic_fetchadd_int((int *) &trunk->ref_count, 1);

Modified: team/qwell/fun_with_transports/apps/app_stack.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/apps/app_stack.c?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/apps/app_stack.c (original)
+++ team/qwell/fun_with_transports/apps/app_stack.c Wed May  8 09:15:51 2013
@@ -40,6 +40,7 @@
 #include "asterisk/manager.h"
 #include "asterisk/channel.h"
 #include "asterisk/agi.h"
+#include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
 	<application name="Gosub" language="en_US">
@@ -202,7 +203,32 @@
 			<para>Cause the channel to execute the specified dialplan subroutine,
 			returning to the dialplan with execution of a Return().</para>
 		</description>
+		<see-also>
+			<ref type="application">GoSub</ref>
+		</see-also>
 	</agi>
+	<managerEvent language="en_US" name="VarSet">
+		<managerEventInstance class="EVENT_FLAG_DIALPLAN">
+			<synopsis>Raised when a variable local to the gosub stack frame is set due to a subroutine call.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Variable">
+					<para>The LOCAL variable being set.</para>
+					<note><para>The variable name will always be enclosed with
+					<literal>LOCAL()</literal></para></note>
+				</parameter>
+				<parameter name="Value">
+					<para>The new value of the variable.</para>
+				</parameter>
+			</syntax>
+			<see-also>
+				<ref type="application">GoSub</ref>
+				<ref type="agi">gosub</ref>
+				<ref type="function">LOCAL</ref>
+				<ref type="function">LOCAL_PEEK</ref>
+			</see-also>
+		</managerEventInstance>
+	</managerEvent>
  ***/
 
 static const char app_gosub[] = "Gosub";
@@ -235,6 +261,8 @@
 {
 	struct ast_var_t *variables;
 	int found = 0;
+	int len;
+	RAII_VAR(char *, local_buffer, NULL, ast_free);
 
 	/* Does this variable already exist? */
 	AST_LIST_TRAVERSE(&frame->varshead, variables, entries) {
@@ -252,20 +280,13 @@
 		pbx_builtin_setvar_helper(chan, var, value);
 	}
 
-	/*** DOCUMENTATION
-	<managerEventInstance>
-		<synopsis>Raised when a LOCAL channel variable is set due to a subroutine call.</synopsis>
-		<see-also>
-			<ref type="application">GoSub</ref>
-		</see-also>
-	</managerEventInstance>
-	***/
-	manager_event(EVENT_FLAG_DIALPLAN, "VarSet",
-		"Channel: %s\r\n"
-		"Variable: LOCAL(%s)\r\n"
-		"Value: %s\r\n"
-		"Uniqueid: %s\r\n",
-		ast_channel_name(chan), var, value, ast_channel_uniqueid(chan));
+	len = 8 + strlen(var); /* LOCAL() + var */
+	local_buffer = ast_malloc(len);
+	if (!local_buffer) {
+		return 0;
+	}
+	sprintf(local_buffer, "LOCAL(%s)", var);
+	ast_channel_publish_varset(chan, local_buffer, value);
 	return 0;
 }
 

Modified: team/qwell/fun_with_transports/build_tools/post_process_documentation.py
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/build_tools/post_process_documentation.py?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/build_tools/post_process_documentation.py (original)
+++ team/qwell/fun_with_transports/build_tools/post_process_documentation.py Wed May  8 09:15:51 2013
@@ -22,9 +22,9 @@
 
     def __swap_parameter_documentation(one, two):
         # See who has the better documentation and use it
-        if (one.hasChildNodes()):
+        if (one.hasChildNodes() and not two.hasChildNodes()):
             two.parentNode.replaceChild(one.cloneNode(True), two)
-        elif (two.hasChildNodes()):
+        elif (two.hasChildNodes() and not one.hasChildNodes()):
             one.parentNode.replaceChild(two.cloneNode(True), one)
 
     def __merge_parameter(param, other_instances):

Modified: team/qwell/fun_with_transports/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_dahdi.c?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_dahdi.c (original)
+++ team/qwell/fun_with_transports/channels/chan_dahdi.c Wed May  8 09:15:51 2013
@@ -3271,7 +3271,7 @@
 		}
 		/* Fall through */
 	default:
-		ast_log(LOG_NOTICE, "PRI got event: %s (%d) on D-channel of span %d\n",
+		ast_log(LOG_NOTICE, "Got DAHDI event: %s (%d) on D-channel of span %d\n",
 			event2str(x), x, pri->span);
 		break;
 	}

Modified: team/qwell/fun_with_transports/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_gulp.c?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_gulp.c (original)
+++ team/qwell/fun_with_transports/channels/chan_gulp.c Wed May  8 09:15:51 2013
@@ -434,7 +434,7 @@
 	pvt->media[SIP_MEDIA_VIDEO] = ao2_find(session->media, "video", OBJ_KEY);
 	ast_channel_tech_pvt_set(chan, pvt);
 
-	if (ast_format_cap_is_empty(session->req_caps)) {
+	if (ast_format_cap_is_empty(session->req_caps) || !ast_format_cap_has_joint(session->req_caps, session->endpoint->codecs)) {
 		ast_format_cap_copy(ast_channel_nativeformats(chan), session->endpoint->codecs);
 	} else {
 		ast_format_cap_copy(ast_channel_nativeformats(chan), session->req_caps);

Modified: team/qwell/fun_with_transports/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_iax2.c?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_iax2.c (original)
+++ team/qwell/fun_with_transports/channels/chan_iax2.c Wed May  8 09:15:51 2013
@@ -283,9 +283,9 @@
 static char language[MAX_LANGUAGE] = "";
 static char regcontext[AST_MAX_CONTEXT] = "";
 
-static struct ast_event_sub *network_change_event_subscription; /*!< subscription id for network change events */
+static struct stasis_subscription *network_change_sub; /*!< subscription id for network change events */
 static struct stasis_subscription *acl_change_sub; /*!< subscription id for ACL change events */
-static int network_change_event_sched_id = -1;
+static int network_change_sched_id = -1;
 
 static int maxauthreq = 3;
 static int max_retries = 4;
@@ -1254,7 +1254,7 @@
 static int get_unused_callno(enum callno_type type, int validated, callno_entry *entry);
 static int replace_callno(const void *obj);
 static void sched_delay_remove(struct sockaddr_in *sin, callno_entry entry);
-static void network_change_event_cb(const struct ast_event *, void *);
+static void network_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message);
 static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message);
 
 static struct ast_channel_tech iax2_tech = {
@@ -1323,18 +1323,18 @@
 	 * is time to send MWI, since it is only sent with a REGACK. */
 }
 
-static void network_change_event_subscribe(void)
-{
-	if (!network_change_event_subscription) {
-		network_change_event_subscription = ast_event_subscribe(AST_EVENT_NETWORK_CHANGE,
-			network_change_event_cb, "IAX2 Network Change", NULL, AST_EVENT_IE_END);
-	}
-}
-
-static void network_change_event_unsubscribe(void)
-{
-	if (network_change_event_subscription) {
-		network_change_event_subscription = ast_event_unsubscribe(network_change_event_subscription);
+static void network_change_stasis_subscribe(void)
+{
+	if (!network_change_sub) {
+		network_change_sub = stasis_subscribe(ast_system_topic(),
+			network_change_stasis_cb, NULL);
+	}
+}
+
+static void network_change_stasis_unsubscribe(void)
+{
+	if (network_change_sub) {
+		network_change_sub = stasis_unsubscribe(network_change_sub);
 	}
 }
 
@@ -1353,10 +1353,10 @@
 	}
 }
 
-static int network_change_event_sched_cb(const void *data)
+static int network_change_sched_cb(const void *data)
 {
 	struct iax2_registry *reg;
-	network_change_event_sched_id = -1;
+	network_change_sched_id = -1;
 	AST_LIST_LOCK(&registrations);
 	AST_LIST_TRAVERSE(&registrations, reg, entry) {
 		iax2_do_register(reg);
@@ -1366,13 +1366,18 @@
 	return 0;
 }
 
-static void network_change_event_cb(const struct ast_event *event, void *userdata)
-{
-	ast_debug(1, "IAX, got a network change event, renewing all IAX registrations.\n");
-	if (network_change_event_sched_id == -1) {
-		network_change_event_sched_id = iax2_sched_add(sched, 1000, network_change_event_sched_cb, NULL);
-	}
-
+static void network_change_stasis_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic, struct stasis_message *message)
+{
+	/* This callback is only concerned with network change messages from the system topic. */
+	if (stasis_message_type(message) != ast_network_change_type()) {
+		return;
+	}
+
+	ast_verb(1, "IAX, got a network change message, renewing all IAX registrations.\n");
+	if (network_change_sched_id == -1) {
+		network_change_sched_id = iax2_sched_add(sched, 1000, network_change_sched_cb, NULL);
+	}
 }
 
 static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub,
@@ -13442,9 +13447,9 @@
 	}
 
 	if (subscribe_network_change) {
-		network_change_event_subscribe();
+		network_change_stasis_subscribe();
 	} else {
-		network_change_event_unsubscribe();
+		network_change_stasis_unsubscribe();
 	}
 
 	if (defaultsockfd < 0) {
@@ -14287,7 +14292,7 @@
 	struct ast_context *con;
 	int x;
 
-	network_change_event_unsubscribe();
+	network_change_stasis_unsubscribe();
 	acl_change_stasis_unsubscribe();
 
 	ast_manager_unregister("IAXpeers");
@@ -14789,7 +14794,7 @@
 
 	ast_realtime_require_field("iaxpeers", "name", RQ_CHAR, 10, "ipaddr", RQ_CHAR, 15, "port", RQ_UINTEGER2, 5, "regseconds", RQ_UINTEGER2, 6, SENTINEL);
 
-	network_change_event_subscribe();
+	network_change_stasis_subscribe();
 
 	return AST_MODULE_LOAD_SUCCESS;
 }

Modified: team/qwell/fun_with_transports/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_sip.c?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_sip.c (original)
+++ team/qwell/fun_with_transports/channels/chan_sip.c Wed May  8 09:15:51 2013
@@ -294,6 +294,7 @@
 #include "sip/include/security_events.h"
 #include "asterisk/sip_api.h"
 #include "asterisk/app.h"
+#include "asterisk/stasis_endpoints.h"
 
 /*** DOCUMENTATION
 	<application name="SIPDtmfMode" language="en_US">
@@ -842,9 +843,9 @@
 static struct ast_flags global_flags[3] = {{0}};  /*!< global SIP_ flags */
 static int global_t38_maxdatagram;                /*!< global T.38 FaxMaxDatagram override */
 
-static struct ast_event_sub *network_change_event_subscription; /*!< subscription id for network change events */
+static struct stasis_subscription *network_change_sub; /*!< subscription id for network change events */
 static struct stasis_subscription *acl_change_sub; /*!< subscription id for named ACL system change events */
-static int network_change_event_sched_id = -1;
+static int network_change_sched_id = -1;
 
 static char used_context[AST_MAX_CONTEXT];        /*!< name of automatically created context for unloading */
 
@@ -1285,7 +1286,7 @@
 static void sip_poke_all_peers(void);
 static void sip_peer_hold(struct sip_pvt *p, int hold);
 static void mwi_event_cb(void *, struct stasis_subscription *, struct stasis_topic *, struct stasis_message *);
-static void network_change_event_cb(const struct ast_event *, void *);
+static void network_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message);
 static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message);
 static void sip_keepalive_all_peers(void);
 
@@ -5324,6 +5325,9 @@
 	peer->caps = ast_format_cap_destroy(peer->caps);
 
 	ast_rtp_dtls_cfg_free(&peer->dtls_cfg);
+
+	ast_endpoint_shutdown(peer->endpoint);
+	peer->endpoint = NULL;
 }
 
 /*! \brief Update peer data in database (if used) */
@@ -8010,6 +8014,14 @@
 		return NULL;
 	}
 
+	if (i->relatedpeer) {
+		if (ast_endpoint_add_channel(i->relatedpeer->endpoint, tmp)) {
+			ast_channel_unref(tmp);
+			sip_pvt_lock(i);
+			return NULL;
+		}
+	}
+
 	/* If we sent in a callid, bind it to the channel. */
 	if (callid) {
 		ast_channel_callid_set(tmp, callid);
@@ -14771,7 +14783,20 @@
 
 	p->pendinginvite = p->ocseq;	/* Remember that we have a pending NOTIFY in order not to confuse the NOTIFY subsystem */
 
-	return send_request(p, &req, XMIT_RELIABLE, p->ocseq);
+	/* Send as XMIT_CRITICAL as we may never receive a 200 OK Response which clears p->pendinginvite.
+	 *
+	 * extensionstate_update() uses p->pendinginvite for queuing control.
+	 * Updates stall if pendinginvite <> 0.
+	 *
+	 * The most appropriate solution is to remove the subscription when the NOTIFY transaction fails.
+	 * The client will re-subscribe after restarting or maxexpiry timeout.
+	 */
+
+	/* RFC6665 4.2.2.  Sending State Information to Subscribers
+	 * If the NOTIFY request fails due to expiration of SIP Timer F (transaction timeout),
+	 * the notifier SHOULD remove the subscription.
+	 */
+	return send_request(p, &req, XMIT_CRITICAL, p->ocseq);
 }
 
 /*! \brief Notify user of messages waiting in voicemail (RFC3842)
@@ -16673,18 +16698,18 @@
 	}
 }
 
-static void network_change_event_subscribe(void)
-{
-	if (!network_change_event_subscription) {
-		network_change_event_subscription = ast_event_subscribe(AST_EVENT_NETWORK_CHANGE,
-			network_change_event_cb, "SIP Network Change", NULL, AST_EVENT_IE_END);
-	}
-}
-
-static void network_change_event_unsubscribe(void)
-{
-	if (network_change_event_subscription) {
-		network_change_event_subscription = ast_event_unsubscribe(network_change_event_subscription);
+static void network_change_stasis_subscribe(void)
+{
+	if (!network_change_sub) {
+		network_change_sub = stasis_subscribe(ast_system_topic(),
+			network_change_stasis_cb, NULL);
+	}
+}
+
+static void network_change_stasis_unsubscribe(void)
+{
+	if (network_change_sub) {
+		network_change_sub = stasis_unsubscribe(network_change_sub);
 	}
 }
 
@@ -16697,26 +16722,31 @@
 
 }
 
-static void acl_change_event_unsubscribe(void)
+static void acl_change_event_stasis_unsubscribe(void)
 {
 	if (acl_change_sub) {
 		acl_change_sub = stasis_unsubscribe(acl_change_sub);
 	}
 }
 
-static int network_change_event_sched_cb(const void *data)
-{
-	network_change_event_sched_id = -1;
+static int network_change_sched_cb(const void *data)
+{
+	network_change_sched_id = -1;
 	sip_send_all_registers();
 	sip_send_all_mwi_subscriptions();
 	return 0;
 }
 
-static void network_change_event_cb(const struct ast_event *event, void *userdata)
-{
-	ast_debug(1, "SIP, got a network change event, renewing all SIP registrations.\n");
-	if (network_change_event_sched_id == -1) {
-		network_change_event_sched_id = ast_sched_add(sched, 1000, network_change_event_sched_cb, NULL);
+static void network_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *message)
+{
+	/* This callback is only concerned with network change messages from the system topic. */
+	if (stasis_message_type(message) != ast_network_change_type()) {
+		return;
+	}
+
+	ast_verb(1, "SIP, got a network change message, renewing all SIP registrations.\n");
+	if (network_change_sched_id == -1) {
+		network_change_sched_id = ast_sched_add(sched, 1000, network_change_sched_cb, NULL);
 	}
 }
 
@@ -30716,6 +30746,9 @@
 			firstpass = 0;
 	} else {
 		if (!(peer = ao2_t_alloc(sizeof(*peer), sip_destroy_peer_fn, "allocate a peer struct"))) {
+			return NULL;
+		}
+		if (!(peer->endpoint = ast_endpoint_create("SIP", name))) {
 			return NULL;
 		}
 		if (!(peer->caps = ast_format_cap_alloc_nolock())) {
@@ -32295,9 +32328,9 @@
 	}
 
 	if (subscribe_network_change) {
-		network_change_event_subscribe();
+		network_change_stasis_subscribe();
 	} else {
-		network_change_event_unsubscribe();
+		network_change_stasis_unsubscribe();
 	}
 
 	if (global_t1 < global_t1min) {
@@ -34771,7 +34804,7 @@
 
 
 	sip_register_tests();
-	network_change_event_subscribe();
+	network_change_stasis_subscribe();
 
 	ast_websocket_add_protocol("sip", sip_websocket_callback);
 
@@ -34791,8 +34824,8 @@
 
 	ast_websocket_remove_protocol("sip", sip_websocket_callback);
 
-	network_change_event_unsubscribe();
-	acl_change_event_unsubscribe();
+	network_change_stasis_unsubscribe();
+	acl_change_event_stasis_unsubscribe();
 
 	ast_sched_dump(sched);
 

Modified: team/qwell/fun_with_transports/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/sip/include/sip.h?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/channels/sip/include/sip.h (original)
+++ team/qwell/fun_with_transports/channels/sip/include/sip.h Wed May  8 09:15:51 2013
@@ -1377,6 +1377,8 @@
 	unsigned int disallowed_methods;
 	struct ast_cc_config_params *cc_params;
 
+	struct ast_endpoint *endpoint;
+
 	struct ast_rtp_dtls_cfg dtls_cfg;
 };
 

Modified: team/qwell/fun_with_transports/funcs/func_global.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/funcs/func_global.c?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/funcs/func_global.c (original)
+++ team/qwell/fun_with_transports/funcs/func_global.c Wed May  8 09:15:51 2013
@@ -39,7 +39,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/channel.h"
 #include "asterisk/app.h"
-#include "asterisk/manager.h"
+#include "asterisk/stasis_channels.h"
 
 /*** DOCUMENTATION
 	<function name="GLOBAL" language="en_US">
@@ -83,7 +83,25 @@
 			using it in a set of calculations (or you might be surprised by the result).</para>
 		</description>
 	</function>
-
+	<managerEvent language="en_US" name="VarSet">
+		<managerEventInstance class="EVENT_FLAG_DIALPLAN">
+			<synopsis>Raised when a variable is shared between channels.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Variable">
+					<para>The SHARED variable being set.</para>
+					<note><para>The variable name will always be enclosed with
+					<literal>SHARED()</literal></para></note>
+				</parameter>
+				<parameter name="Value">
+					<para>The new value of the variable.</para>
+				</parameter>
+			</syntax>
+			<see-also>
+				<ref type="function">SHARED</ref>
+			</see-also>
+		</managerEventInstance>
+	</managerEvent>
  ***/
 
 static void shared_variable_free(void *data);
@@ -197,6 +215,8 @@
 		AST_APP_ARG(chan);
 	);
 	struct ast_channel *c_ref = NULL;
+	int len;
+	RAII_VAR(char *, shared_buffer, NULL, ast_free);
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "SHARED() requires an argument: SHARED(<var>[,<chan>])\n");
@@ -213,6 +233,15 @@
 			return -1;
 		}
 		chan = c_ref;
+	}
+
+	len = 9 + strlen(args.var); /* SHARED() + var */
+	shared_buffer = ast_malloc(len);
+	if (!shared_buffer) {
+		if (c_ref) {
+			ast_channel_unref(c_ref);
+		}
+		return -1;
 	}
 
 	ast_channel_lock(chan);
@@ -255,13 +284,9 @@
 
 	var = ast_var_assign(args.var, S_OR(value, ""));
 	AST_LIST_INSERT_HEAD(varshead, var, entries);
-	manager_event(EVENT_FLAG_DIALPLAN, "VarSet", 
-		"Channel: %s\r\n"
-		"Variable: SHARED(%s)\r\n"
-		"Value: %s\r\n"
-		"Uniqueid: %s\r\n", 
-		chan ? ast_channel_name(chan) : "none", args.var, value, 
-		chan ? ast_channel_uniqueid(chan) : "none");
+
+	sprintf(shared_buffer, "SHARED(%s)", args.var);
+	ast_channel_publish_varset(chan, shared_buffer, value);
 
 	ast_channel_unlock(chan);
 

Modified: team/qwell/fun_with_transports/include/asterisk.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/include/asterisk.h?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/include/asterisk.h (original)
+++ team/qwell/fun_with_transports/include/asterisk.h Wed May  8 09:15:51 2013
@@ -200,6 +200,27 @@
 #define ast_mark(a, b) do { } while (0)
 #endif /* LOW_MEMORY */
 
+/*!
+ * \since 12
+ * \brief A \ref stasis topic which publishes messages regarding system changes
+ *
+ * \retval \ref stasis_topic for system level changes
+ * \retval NULL on error
+ */
+struct stasis_topic *ast_system_topic(void);
+
+/*!
+ * \since 12
+ * \brief A \ref stasis_message_type for network changes
+ *
+ * \retval NULL on error
+ * \retval \ref stasis_message_type for network changes
+ *
+ * \note Messages of this type should always be issued on and expected from
+ *       the \ref ast_system_topic \ref stasis topic
+ */
+struct stasis_message_type *ast_network_change_type(void);
+
 /*! \brief
  * Definition of various structures that many asterisk files need,
  * but only because they need to know that the type exists.

Modified: team/qwell/fun_with_transports/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/include/asterisk/astobj2.h?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/include/asterisk/astobj2.h (original)
+++ team/qwell/fun_with_transports/include/asterisk/astobj2.h Wed May  8 09:15:51 2013
@@ -383,12 +383,19 @@
 
 
 
-/*! \brief
- * Typedef for an object destructor. This is called just before freeing
- * the memory for the object. It is passed a pointer to the user-defined
- * data of the object.
- */
-typedef void (*ao2_destructor_fn)(void *);
+/*!
+ * \brief Typedef for an object destructor.
+ *
+ * \param vdoomed Object to destroy.
+ *
+ * \details
+ * This is called just before freeing the memory for the object.
+ * It is passed a pointer to the user-defined data of the
+ * object.
+ *
+ * \return Nothing
+ */
+typedef void (*ao2_destructor_fn)(void *vdoomed);
 
 /*! \brief Options available when allocating an ao2 object. */
 enum ao2_alloc_opts {
@@ -1883,4 +1890,55 @@
 #define ao2_cleanup(obj) __ao2_cleanup(obj)
 #endif
 void ao2_iterator_cleanup(struct ao2_iterator *iter);
+
+
+/* XXX TODO BUGBUG and all the other things...
+ * These functions should eventually be moved elsewhere, but the utils folder
+ * won't compile with them in strings.h
+ */
+
+/*!
+ * \since 12
+ * \brief Allocates a hash container for bare strings
+ *
+ * \param buckets The number of buckets to use for the hash container
+ *
+ * \retval AO2 container for strings
+ * \retval NULL if allocation failed
+ */
+#define ast_str_container_alloc(buckets) ast_str_container_alloc_options(AO2_ALLOC_OPT_LOCK_MUTEX, buckets)
+
+/*!
+ * \since 12
+ * \brief Allocates a hash container for bare strings
+ *
+ * \param opts Options to be provided to the container
+ * \param buckets The number of buckets to use for the hash container
+ *
+ * \retval AO2 container for strings
+ * \retval NULL if allocation failed
+ */
+struct ao2_container *ast_str_container_alloc_options(enum ao2_container_opts opts, int buckets);
+
+/*!
+ * \since 12
+ * \brief Adds a string to a string container allocated by ast_str_container_alloc
+ *
+ * \param str_container The container to which to add a string
+ * \param add The string to add to the container
+ *
+ * \retval zero on success
+ * \retval non-zero if the operation failed
+ */
+int ast_str_container_add(struct ao2_container *str_container, const char *add);
+
+/*!
+ * \since 12
+ * \brief Removes a string from a string container allocated by ast_str_container_alloc
+ *
+ * \param str_container The container from which to remove a string
+ * \param remove The string to remove from the container
+ */
+void ast_str_container_remove(struct ao2_container *str_container, const char *remove);
+
 #endif /* _ASTERISK_ASTOBJ2_H */

Modified: team/qwell/fun_with_transports/include/asterisk/json.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/include/asterisk/json.h?view=diff&rev=387935&r1=387934&r2=387935
==============================================================================
--- team/qwell/fun_with_transports/include/asterisk/json.h (original)
+++ team/qwell/fun_with_transports/include/asterisk/json.h Wed May  8 09:15:51 2013
@@ -24,9 +24,54 @@
  * \brief Asterisk JSON abstraction layer.
  * \since 12.0.0
  *
- * This is a very thin wrapper around the Jansson API. For more details on it, see its
- * docs at http://www.digip.org/jansson/doc/2.4/apiref.html.
-
+ * This is a very thin wrapper around the Jansson API. For more details on it,
+ * see its docs at http://www.digip.org/jansson/doc/2.4/apiref.html.
+ *
+ * Rather than provide the multiple ways of doing things that the Jansson API
+ * does, the Asterisk wrapper is always reference-stealing, and always NULL
+ * safe.
+ *
+ * And by always, I mean that the reference is stolen even if the function
+ * fails. This avoids lots of conditional logic, and also avoids having to track
+ * zillions of local variables when building complex JSON objects. You can
+ * instead chain \c ast_json_* calls together safely and only worry about
+ * cleaning up the root object.
+ *
+ * In the cases where you have a need to introduce intermediate objects, just
+ * wrap them with json_ref() when passing them to other \c ast_json_*()
+ * functions.
+ *
+ * \code
+ *	// Example of how to use the Asterisk JSON API
+ *	static struct ast_json *foo(void) {
+ *		RAII_VAR(struct ast_json *, array, NULL, ast_json_unref);
+ *		RAII_VAR(struct ast_json *, obj, NULL, ast_json_unref);
+ *		int i, res;
+ *
+ *		array = ast_json_array_create();
+ *		if (!array) { return NULL; }
+ *
+ *		for (i = 0; i < 10; ++i) {
+ *			// NULL safety and object stealing means calls can
+ *			// be chained together directly.
+ *			res = ast_json_array_append(array,
+ *				ast_json_integer_create(i));
+ *			if (res != 0) { return NULL; }
+ *		}
+ *
+ *		obj = ast_json_object_create();
+ *		if (!obj) { return NULL; }
+ *
+ *		// If you already have an object reference, ast_json_ref()
+ *		// can be used inline to bump the ref before passing it along
+ *		// to a ref-stealing call
+ *		res = ast_json_object_set(obj, "foo", ast_json_ref(array));
+ *		if (!res) { return NULL; }
+ *
+ *		return obj;
+ *	}
+ * \endcode
+ *
  * \author David M. Lee, II <dlee at digium.com>
  */
 


[... 1868 lines stripped ...]



More information about the asterisk-commits mailing list