[asterisk-commits] qwell: branch qwell/queue_events r390287 - in /team/qwell/queue_events: ./ ad...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 31 10:25:17 CDT 2013


Author: qwell
Date: Fri May 31 10:25:01 2013
New Revision: 390287

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390287
Log:
Multiple revisions 389974,389990,390042,390068,390122,390154,390180,390230,390249-390250,390268

........
  r389974 | kmoore | 2013-05-28 21:26:17 -0500 (Tue, 28 May 2013) | 9 lines
  
  Resolve a merge conflict
  
  When ast_channel_cached_blob_create was merged,
  ast_channel_blob_create_from_cache was partially removed in an
  unresolved merge conflict. This restores ast_channel_blob_create_from_cache
  and refactors usage of ast_channel_cached_blob_create (requires an
  ast_channel) to use ast_channel_blob_create_from_cache (requires a
  channel uniqueid) instead.
........
  r389990 | mjordan | 2013-05-28 22:22:04 -0500 (Tue, 28 May 2013) | 5 lines
  
  Pack the right number of items into the status and receive fax blobs
  
  The code was still attempting to pack an additional item into the blobs
  that didn't exist. Crashes ensued. This patch modifies the publishing of
  these messages so that the correct number of items are packed in the JSON.
........
  r390042 | qwell | 2013-05-29 14:54:01 -0500 (Wed, 29 May 2013) | 1 line
  
  Remove unused RAII vars.
........
  r390068 | rmudgett | 2013-05-29 15:24:18 -0500 (Wed, 29 May 2013) | 18 lines
  
  Fix segfault when dealing with chan_agent channels.
  
  Check the returned bridged pointer for NULL to avoid a crash.  It looks
  like chan_agent is returning a NULL pointer when it probably should be
  returning a pointer to the channel the Agent channel is pretending to be.
  
  (closes issue ASTERISK-21793)
  Reported by: Rodrigo P. Telles
  Patches:
        jira_asterisk_21793_v1.8.patch (license #5621) patch uploaded by rmudgett
  Tested by: Rodrigo P. Telles
  ........
  
  Merged revisions 390044 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 390047 from http://svn.asterisk.org/svn/asterisk/branches/11
........
  r390122 | dlee | 2013-05-30 12:05:53 -0500 (Thu, 30 May 2013) | 34 lines
  
  Avoid unnecessary cleanups during immediate shutdown
  
  This patch addresses issues during immediate shutdowns, where modules
  are not unloaded, but Asterisk atexit handlers are run.
  
  In the typical case, this usually isn't a big deal. But the
  introduction of the Stasis message bus makes it much more likely for
  asynchronous activity to be happening off in some thread during
  shutdown.
  
  During an immediate shutdown, Asterisk skips unloading modules. But
  while it is processing the atexit handlers, there is a window of time
  where some of the core message types have been cleaned up, but the
  message bus is still running. Specifically, it's still running
  module subscriptions that might be using the core message types. If a
  message is received by that subscription in that window, it will
  attempt to use a message type that has been cleaned up.
  
  To solve this problem, this patch introduces ast_register_cleanup().
  This function operates identically to ast_register_atexit(), except
  that cleanup calls are not invoked on an immediate shutdown. All of
  the core message type and topic cleanup was moved from atexit handlers
  to cleanup handlers.
  
  This ensures that core type and topic cleanup only happens if the
  modules that used them are first unloaded.
  
  This patch also changes the ast_assert() when accessing a cleaned up
  or uninitialized message type to an error log message. Message type
  functions are actually NULL safe across the board, so the assert was a
  bit heavy handed. Especially for anyone with DO_CRASH enabled.
  
  Review: https://reviewboard.asterisk.org/r/2562/
........
  r390154 | dlee | 2013-05-30 14:23:53 -0500 (Thu, 30 May 2013) | 1 line
  
  Missed a line from a bad merge in r390122
........
  r390180 | wdoekes | 2013-05-31 02:57:28 -0500 (Fri, 31 May 2013) | 4 lines
  
  Let find do its own globbing.
  
  Previously a stray .c file would cause xmldocs to not get built.
........
  r390230 | may | 2013-05-31 05:42:19 -0500 (Fri, 31 May 2013) | 27 lines
  
  Multiple revisions 390228-390229
  
  ........
    r390228 | may | 2013-05-31 14:19:52 +0400 (Fri, 31 May 2013) | 14 lines
    
    reject call attempts when gatekeeper is configured but not registered
    
    (closes issue ASTERISK-21800)
    Reported by: Dmitry Melekhov
    Patches:
            ASTERISK-21800-1.patch
    Tested by: Dmitry Melekhov
    ........
    
    Merged revisions 390181 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 390223 from http://svn.asterisk.org/svn/asterisk/branches/10
  ........
    r390229 | may | 2013-05-31 14:34:20 +0400 (Fri, 31 May 2013) | 4 lines
    
    remove unnecessary declarations
    (issue ASTERISK-21800)
  ........
  
  Merged revisions 390228-390229 from http://svn.asterisk.org/svn/asterisk/branches/11
........
  r390249 | kmoore | 2013-05-31 07:27:29 -0500 (Fri, 31 May 2013) | 8 lines
  
  Add snapshot cache that indexes by channel name
  
  This adds a new channel snapshot cache in parallel to the existing
  cache; the difference being that it indexes the channel snapshots by
  channel name instead of channel uniqueid.
  
  Review: https://reviewboard.asterisk.org/r/2576
........
  r390250 | kmoore | 2013-05-31 07:41:10 -0500 (Fri, 31 May 2013) | 8 lines
  
  Remove remnant of snapshot blob JSON types
  
  Remove usage of the once-mandatory snapshot blob type field, refactor
  confbridge stasis messages accordingly, and remove
  ast_bridge_blob_json_type().
  
  Review: https://reviewboard.asterisk.org/r/2575/
........
  r390268 | qwell | 2013-05-31 09:36:08 -0500 (Fri, 31 May 2013) | 7 lines
  
  Replace ast_manager_publish_message() with a more useful version.
  
  It's much easier to just create a blob of the message.  Convert some AMI events
  to use it.
  
  Review: https://reviewboard.asterisk.org/r/2577/
........

Merged revisions 389974,389990,390042,390068,390122,390154,390180,390230,390249-390250,390268 from http://svn.asterisk.org/svn/asterisk/trunk

Modified:
    team/qwell/queue_events/   (props changed)
    team/qwell/queue_events/Makefile
    team/qwell/queue_events/addons/chan_ooh323.c
    team/qwell/queue_events/apps/app_confbridge.c
    team/qwell/queue_events/apps/app_fax.c
    team/qwell/queue_events/apps/confbridge/confbridge_manager.c
    team/qwell/queue_events/apps/confbridge/include/confbridge.h
    team/qwell/queue_events/include/asterisk.h
    team/qwell/queue_events/include/asterisk/manager.h
    team/qwell/queue_events/include/asterisk/security_events.h
    team/qwell/queue_events/include/asterisk/stasis.h
    team/qwell/queue_events/include/asterisk/stasis_bridging.h
    team/qwell/queue_events/include/asterisk/stasis_channels.h
    team/qwell/queue_events/main/app.c
    team/qwell/queue_events/main/asterisk.c
    team/qwell/queue_events/main/bridging.c
    team/qwell/queue_events/main/channel.c
    team/qwell/queue_events/main/devicestate.c
    team/qwell/queue_events/main/manager.c
    team/qwell/queue_events/main/named_acl.c
    team/qwell/queue_events/main/presencestate.c
    team/qwell/queue_events/main/security_events.c
    team/qwell/queue_events/main/stasis.c
    team/qwell/queue_events/main/stasis_bridging.c
    team/qwell/queue_events/main/stasis_cache.c
    team/qwell/queue_events/main/stasis_channels.c
    team/qwell/queue_events/main/test.c
    team/qwell/queue_events/res/res_fax.c
    team/qwell/queue_events/res/res_monitor.c
    team/qwell/queue_events/res/res_musiconhold.c

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

Propchange: team/qwell/queue_events/
------------------------------------------------------------------------------
    svnmerge-integrated = /trunk:1-390276

Modified: team/qwell/queue_events/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/Makefile?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/Makefile (original)
+++ team/qwell/queue_events/Makefile Fri May 31 10:25:01 2013
@@ -468,7 +468,7 @@
 	@echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
 	@for x in $(MOD_SUBDIRS); do \
 		printf "$$x " ; \
-		for i in `find $$x -name *.c`; do \
+		for i in `find $$x -name '*.c'`; do \
 			$(AWK) -f build_tools/get_documentation $$i >> $@ ; \
 		done ; \
 	done

Modified: team/qwell/queue_events/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/addons/chan_ooh323.c?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/addons/chan_ooh323.c (original)
+++ team/qwell/queue_events/addons/chan_ooh323.c Fri May 31 10:25:01 2013
@@ -307,6 +307,8 @@
 int onCallCleared(ooCallData *call);
 void onModeChanged(ooCallData *call, int t38mode);
 
+extern OOH323EndPoint gH323ep;
+
 static char gLogFile[256] = DEFAULT_LOGFILE;
 static int  gPort = 1720;
 static char gIP[2+8*4+7];	/* Max for IPv6 addr */
@@ -642,6 +644,7 @@
 		ooh323_destroy(p);
 		ast_mutex_unlock(&iflock);
 		ast_log(LOG_ERROR, "Destination format is not supported\n");
+		*cause = AST_CAUSE_INVALID_NUMBER_FORMAT;
 		return NULL;
 	}
 
@@ -688,6 +691,10 @@
 			ast_mutex_unlock(&p->lock);
 			ooh323_destroy(p);
 			ast_mutex_unlock(&iflock);
+			return NULL;
+		} else if (gH323ep.gkClient && gH323ep.gkClient->state != GkClientRegistered) {
+			ast_log(LOG_ERROR, "Gatekeeper client is configured but not registered\n");
+			*cause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
 			return NULL;
 		}
 		p->g729onlyA = g729onlyA;
@@ -2615,8 +2622,6 @@
 
 static int ooh323_do_reload(void)
 {
-	extern OOH323EndPoint gH323ep;
-
 	if (gH323Debug) {
 		ast_verb(0, "---   ooh323_do_reload\n");
 	}
@@ -3369,7 +3374,6 @@
 static char *handle_cli_ooh323_show_gk(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	char value[FORMAT_STRING_SIZE];
-	extern OOH323EndPoint gH323ep;
 
 	switch (cmd) {
 	case CLI_INIT:

Modified: team/qwell/queue_events/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/apps/app_confbridge.c?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/apps/app_confbridge.c (original)
+++ team/qwell/queue_events/apps/app_confbridge.c Fri May 31 10:25:01 2013
@@ -415,13 +415,12 @@
 	return "";
 }
 
-static void send_conf_stasis(struct confbridge_conference *conference, struct ast_channel *chan, const char *type, struct ast_json *extras, int channel_topic)
+static void send_conf_stasis(struct confbridge_conference *conference, struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *extras, int channel_topic)
 {
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
 
-	json_object = ast_json_pack("{s: s, s: s}",
-		"type", type,
+	json_object = ast_json_pack("{s: s}",
 		"conference", conference->name);
 
 	if (!json_object) {
@@ -432,10 +431,10 @@
 		ast_json_object_update(json_object, extras);
 	}
 
-	msg = ast_bridge_blob_create(confbridge_message_type(),
-					 conference->bridge,
-					 chan,
-					 json_object);
+	msg = ast_bridge_blob_create(type,
+		conference->bridge,
+		chan,
+		json_object);
 	if (!msg) {
 		return;
 	}
@@ -450,42 +449,42 @@
 
 static void send_conf_start_event(struct confbridge_conference *conference)
 {
-	send_conf_stasis(conference, NULL, "confbridge_start", NULL, 0);
+	send_conf_stasis(conference, NULL, confbridge_start_type(), NULL, 0);
 }
 
 static void send_conf_end_event(struct confbridge_conference *conference)
 {
-	send_conf_stasis(conference, NULL, "confbridge_end", NULL, 0);
+	send_conf_stasis(conference, NULL, confbridge_end_type(), NULL, 0);
 }
 
 static void send_join_event(struct ast_channel *chan, struct confbridge_conference *conference)
 {
-	send_conf_stasis(conference, chan, "confbridge_join", NULL, 0);
+	send_conf_stasis(conference, chan, confbridge_join_type(), NULL, 0);
 }
 
 static void send_leave_event(struct ast_channel *chan, struct confbridge_conference *conference)
 {
-	send_conf_stasis(conference, chan, "confbridge_leave", NULL, 0);
+	send_conf_stasis(conference, chan, confbridge_leave_type(), NULL, 0);
 }
 
 static void send_start_record_event(struct confbridge_conference *conference)
 {
-	send_conf_stasis(conference, NULL, "confbridge_record", NULL, 0);
+	send_conf_stasis(conference, NULL, confbridge_start_record_type(), NULL, 0);
 }
 
 static void send_stop_record_event(struct confbridge_conference *conference)
 {
-	send_conf_stasis(conference, NULL, "confbridge_stop_record", NULL, 0);
+	send_conf_stasis(conference, NULL, confbridge_stop_record_type(), NULL, 0);
 }
 
 static void send_mute_event(struct ast_channel *chan, struct confbridge_conference *conference)
 {
-	send_conf_stasis(conference, chan, "confbridge_mute", NULL, 1);
+	send_conf_stasis(conference, chan, confbridge_mute_type(), NULL, 1);
 }
 
 static void send_unmute_event(struct ast_channel *chan, struct confbridge_conference *conference)
 {
-	send_conf_stasis(conference, chan, "confbridge_unmute", NULL, 1);
+	send_conf_stasis(conference, chan, confbridge_unmute_type(), NULL, 1);
 }
 
 static void set_rec_filename(struct confbridge_conference *conference, struct ast_str **filename, int is_new)
@@ -1420,7 +1419,7 @@
 		return;
 	}
 
-	send_conf_stasis(conference, bridge_channel->chan, "confbridge_talking", talking_extras, 0);
+	send_conf_stasis(conference, bridge_channel->chan, confbridge_talking_type(), talking_extras, 0);
 	ast_json_unref(talking_extras);
 }
 

Modified: team/qwell/queue_events/apps/app_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/apps/app_fax.c?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/apps/app_fax.c (original)
+++ team/qwell/queue_events/apps/app_fax.c Fri May 31 10:25:01 2013
@@ -268,7 +268,7 @@
 			"fax_resolution", stat.y_resolution,
 			"fax_bitrate", stat.bit_rate,
 			"filenames", json_filenames);
-	message = ast_channel_cached_blob_create(s->chan, ast_channel_fax_type(), json_object);
+	message = ast_channel_blob_create_from_cache(ast_channel_uniqueid(s->chan), ast_channel_fax_type(), json_object);
 	if (!message) {
 		return;
 	}

Modified: team/qwell/queue_events/apps/confbridge/confbridge_manager.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/apps/confbridge/confbridge_manager.c?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/apps/confbridge/confbridge_manager.c (original)
+++ team/qwell/queue_events/apps/confbridge/confbridge_manager.c Fri May 31 10:25:01 2013
@@ -206,61 +206,24 @@
 		header, value);
 }
 
-static void stasis_confbridge_cb(void *data, struct stasis_subscription *sub,
-					struct stasis_topic *topic,
-					struct stasis_message *message)
+static void confbridge_publish_manager_event(
+	struct stasis_message *message,
+	const char *event,
+	struct ast_str *extra_text)
 {
 	struct ast_bridge_blob *blob = stasis_message_data(message);
-	const char *type = ast_bridge_blob_json_type(blob);
 	const char *conference_name;
-	RAII_VAR(struct ast_str *, bridge_text, NULL, ast_free);
+	RAII_VAR(struct ast_str *, bridge_text,
+		ast_manager_build_bridge_state_string(blob->bridge, ""),
+		ast_free);
 	RAII_VAR(struct ast_str *, channel_text, NULL, ast_free);
-	RAII_VAR(struct ast_str *, extra_text, NULL, ast_free);
-	char *event;
-
-	if (!blob || !type) {
-		ast_assert(0);
-		return;
-	}
-
-	if (!strcmp("confbridge_start", type)) {
-		event = "ConfbridgeStart";
-	} else if (!strcmp("confbridge_end", type)) {
-		event = "ConfbridgeEnd";
-	} else if (!strcmp("confbridge_leave", type)) {
-		event = "ConfbridgeLeave";
-	} else if (!strcmp("confbridge_join", type)) {
-		event = "ConfbridgeJoin";
-	} else if (!strcmp("confbridge_record", type)) {
-		event = "ConfbridgeRecord";
-	} else if (!strcmp("confbridge_stop_record", type)) {
-		event = "ConfbridgeStopRecord";
-	} else if (!strcmp("confbridge_mute", type)) {
-		event = "ConfbridgeMute";
-	} else if (!strcmp("confbridge_unmute", type)) {
-		event = "ConfbridgeUnmute";
-	} else if (!strcmp("confbridge_talking", type)) {
-		const char *talking_status = ast_json_string_get(ast_json_object_get(blob->blob, "talking_status"));
-		event = "ConfbridgeTalking";
-
-		if (!talking_status) {
-			return;
-		}
-
-		append_event_header(&extra_text, "TalkingStatus", talking_status);
-
-	} else {
-		return;
-	}
+
+	ast_assert(blob != NULL);
+	ast_assert(event != NULL);
 
 	conference_name = ast_json_string_get(ast_json_object_get(blob->blob, "conference"));
-
-	if (!conference_name) {
-		ast_assert(0);
-		return;
-	}
-
-	bridge_text = ast_manager_build_bridge_state_string(blob->bridge, "");
+	ast_assert(conference_name != NULL);
+
 	if (blob->channel) {
 		channel_text = ast_manager_build_channel_state_string(blob->channel);
 	}
@@ -272,20 +235,105 @@
 		"%s",
 		conference_name,
 		ast_str_buffer(bridge_text),
-		channel_text ? ast_str_buffer(channel_text) : "",
-		extra_text ? ast_str_buffer(extra_text) : "");
-}
-
-static struct stasis_message_type *confbridge_msg_type;
-
-struct stasis_message_type *confbridge_message_type(void)
-{
-	return confbridge_msg_type;
-}
+		S_COR(channel_text, ast_str_buffer(channel_text), ""),
+		S_COR(extra_text, ast_str_buffer(extra_text), ""));
+}
+
+static void confbridge_start_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	confbridge_publish_manager_event(message, "ConfbridgeStart", NULL);
+}
+
+static void confbridge_end_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	confbridge_publish_manager_event(message, "ConfbridgeEnd", NULL);
+}
+
+static void confbridge_leave_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	confbridge_publish_manager_event(message, "ConfbridgeLeave", NULL);
+}
+
+static void confbridge_join_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	confbridge_publish_manager_event(message, "ConfbridgeJoin", NULL);
+}
+
+static void confbridge_start_record_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	confbridge_publish_manager_event(message, "ConfbridgeRecord", NULL);
+}
+
+static void confbridge_stop_record_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	confbridge_publish_manager_event(message, "ConfbridgeStopRecord", NULL);
+}
+
+static void confbridge_mute_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	confbridge_publish_manager_event(message, "ConfbridgeMute", NULL);
+}
+
+static void confbridge_unmute_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	confbridge_publish_manager_event(message, "ConfbridgeUnmute", NULL);
+}
+
+static void confbridge_talking_cb(void *data, struct stasis_subscription *sub,
+	struct stasis_topic *topic,
+	struct stasis_message *message)
+{
+	RAII_VAR(struct ast_str *, extra_text, NULL, ast_free);
+	struct ast_bridge_blob *blob = stasis_message_data(message);
+	const char *talking_status = ast_json_string_get(ast_json_object_get(blob->blob, "talking_status"));
+	if (!talking_status) {
+		return;
+	}
+
+	append_event_header(&extra_text, "TalkingStatus", talking_status);
+	if (!extra_text) {
+		return;
+	}
+
+	confbridge_publish_manager_event(message, "ConfbridgeTalking", extra_text);
+}
+
+STASIS_MESSAGE_TYPE_DEFN(confbridge_start_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_end_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_join_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_leave_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_start_record_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_stop_record_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_mute_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_unmute_type);
+STASIS_MESSAGE_TYPE_DEFN(confbridge_talking_type);
 
 void manager_confbridge_shutdown(void) {
-	ao2_cleanup(confbridge_msg_type);
-	confbridge_msg_type = NULL;
+	STASIS_MESSAGE_TYPE_CLEANUP(confbridge_start_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(confbridge_end_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(confbridge_join_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(confbridge_leave_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(confbridge_start_record_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(confbridge_stop_record_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(confbridge_mute_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(confbridge_unmute_type);
+	STASIS_MESSAGE_TYPE_CLEANUP(confbridge_talking_type);
 
 	if (bridge_state_router) {
 		stasis_message_router_unsubscribe(bridge_state_router);
@@ -300,9 +348,15 @@
 
 int manager_confbridge_init(void)
 {
-	if (!(confbridge_msg_type = stasis_message_type_create("confbridge"))) {
-		return -1;
-	}
+	STASIS_MESSAGE_TYPE_INIT(confbridge_start_type);
+	STASIS_MESSAGE_TYPE_INIT(confbridge_end_type);
+	STASIS_MESSAGE_TYPE_INIT(confbridge_join_type);
+	STASIS_MESSAGE_TYPE_INIT(confbridge_leave_type);
+	STASIS_MESSAGE_TYPE_INIT(confbridge_start_record_type);
+	STASIS_MESSAGE_TYPE_INIT(confbridge_stop_record_type);
+	STASIS_MESSAGE_TYPE_INIT(confbridge_mute_type);
+	STASIS_MESSAGE_TYPE_INIT(confbridge_unmute_type);
+	STASIS_MESSAGE_TYPE_INIT(confbridge_talking_type);
 
 	bridge_state_router = stasis_message_router_create(
 		stasis_caching_get_topic(ast_bridge_topic_all_cached()));
@@ -312,9 +366,65 @@
 	}
 
 	if (stasis_message_router_add(bridge_state_router,
-					 confbridge_message_type(),
-					 stasis_confbridge_cb,
-					 NULL)) {
+			confbridge_start_type(),
+			confbridge_start_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(bridge_state_router,
+			confbridge_end_type(),
+			confbridge_end_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(bridge_state_router,
+			confbridge_join_type(),
+			confbridge_join_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(bridge_state_router,
+			confbridge_leave_type(),
+			confbridge_leave_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(bridge_state_router,
+			confbridge_start_record_type(),
+			confbridge_start_record_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(bridge_state_router,
+			confbridge_stop_record_type(),
+			confbridge_stop_record_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(bridge_state_router,
+			confbridge_mute_type(),
+			confbridge_mute_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(bridge_state_router,
+			confbridge_unmute_type(),
+			confbridge_unmute_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(bridge_state_router,
+			confbridge_talking_type(),
+			confbridge_talking_cb,
+			NULL)) {
 		manager_confbridge_shutdown();
 		return -1;
 	}
@@ -328,9 +438,65 @@
 	}
 
 	if (stasis_message_router_add(channel_state_router,
-					 confbridge_message_type(),
-					 stasis_confbridge_cb,
-					 NULL)) {
+			confbridge_start_type(),
+			confbridge_start_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(channel_state_router,
+			confbridge_end_type(),
+			confbridge_end_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(channel_state_router,
+			confbridge_join_type(),
+			confbridge_join_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(channel_state_router,
+			confbridge_leave_type(),
+			confbridge_leave_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(channel_state_router,
+			confbridge_start_record_type(),
+			confbridge_start_record_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(channel_state_router,
+			confbridge_stop_record_type(),
+			confbridge_stop_record_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(channel_state_router,
+			confbridge_mute_type(),
+			confbridge_mute_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(channel_state_router,
+			confbridge_unmute_type(),
+			confbridge_unmute_cb,
+			NULL)) {
+		manager_confbridge_shutdown();
+		return -1;
+	}
+	if (stasis_message_router_add(channel_state_router,
+			confbridge_talking_type(),
+			confbridge_talking_cb,
+			NULL)) {
 		manager_confbridge_shutdown();
 		return -1;
 	}

Modified: team/qwell/queue_events/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/apps/confbridge/include/confbridge.h?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/apps/confbridge/include/confbridge.h (original)
+++ team/qwell/queue_events/apps/confbridge/include/confbridge.h Fri May 31 10:25:01 2013
@@ -465,12 +465,84 @@
 
 /*!
  * \since 12.0
- * \brief get the confbridge stasis message type
- *
- * \retval stasis message type for confbridge messages if it's available
- * \retval NULL if it isn't
- */
-struct stasis_message_type *confbridge_message_type(void);
+ * \brief get the confbridge start stasis message type
+ *
+ * \retval stasis message type for confbridge start messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_start_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge end stasis message type
+ *
+ * \retval stasis message type for confbridge end messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_end_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge join stasis message type
+ *
+ * \retval stasis message type for confbridge join messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_join_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge leave stasis message type
+ *
+ * \retval stasis message type for confbridge leave messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_leave_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge start_record stasis message type
+ *
+ * \retval stasis message type for confbridge start_record messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_start_record_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge stop_record stasis message type
+ *
+ * \retval stasis message type for confbridge stop_record messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_stop_record_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge mute stasis message type
+ *
+ * \retval stasis message type for confbridge mute messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_mute_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge unmute stasis message type
+ *
+ * \retval stasis message type for confbridge unmute messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_unmute_type(void);
+
+/*!
+ * \since 12.0
+ * \brief get the confbridge talking stasis message type
+ *
+ * \retval stasis message type for confbridge talking messages if it's available
+ * \retval NULL if it isn't
+ */
+struct stasis_message_type *confbridge_talking_type(void);
 
 /*!
  * \since 12.0

Modified: team/qwell/queue_events/include/asterisk.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/include/asterisk.h?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/include/asterisk.h (original)
+++ team/qwell/queue_events/include/asterisk.h Fri May 31 10:25:01 2013
@@ -90,6 +90,22 @@
 int ast_register_atexit(void (*func)(void));
 
 /*!
+ * \since 12
+ * \brief Register a function to be executed before Asterisk gracefully exits.
+ *
+ * If Asterisk is immediately shutdown (core stop now, or sending the TERM
+ * signal), the callback is not run. When the callbacks are run, they are run in
+ * sequence with ast_register_atexit() callbacks, in the reverse order of
+ * registration.
+ *
+ * \param func The callback function to use.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_register_cleanup(void (*func)(void));
+
+/*!
  * \brief Unregister a function registered with ast_register_atexit().
  * \param func The callback function to unregister.
  */

Modified: team/qwell/queue_events/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/include/asterisk/manager.h?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/include/asterisk/manager.h (original)
+++ team/qwell/queue_events/include/asterisk/manager.h Fri May 31 10:25:01 2013
@@ -475,17 +475,18 @@
 
 /*!
  * \since 12
- * \brief Publish a generic \ref stasis_message_type to the \ref stasis_topic for AMI
+ * \brief Publish an event to AMI
+ *
+ * \param type The type of AMI event to publish
+ * \param class_type The class on which to publish the event
+ * \param obj The event data to be published.
  *
  * Publishes a message to the \ref stasis message bus solely for the consumption of AMI.
  * The message will be of the type provided by \ref ast_manager_get_type, and will be
  * published to the topic provided by \ref ast_manager_get_topic. As such, the JSON must
  * be constructed as defined by the \ref ast_manager_get_type message.
- *
- * \retval 0 on success
- * \retval -1 on failure
- */
-int ast_manager_publish_message(struct ast_json *json);
+ */
+void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj);
 
 /*!
  * \since 12

Modified: team/qwell/queue_events/include/asterisk/security_events.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/include/asterisk/security_events.h?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/include/asterisk/security_events.h (original)
+++ team/qwell/queue_events/include/asterisk/security_events.h Fri May 31 10:25:01 2013
@@ -87,12 +87,6 @@
 int ast_security_stasis_init(void);
 
 /*!
- * \brief removes stasis topic/event types for \ref ast_security_topic and \ref ast_security_event_type
- * \since 12
- */
-void ast_security_stasis_cleanup(void);
-
-/*!
  * \brief Get the list of required IEs for a given security event sub-type
  *
  * \param[in] event_type security event sub-type

Modified: team/qwell/queue_events/include/asterisk/stasis.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/include/asterisk/stasis.h?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/include/asterisk/stasis.h (original)
+++ team/qwell/queue_events/include/asterisk/stasis.h Fri May 31 10:25:01 2013
@@ -633,6 +633,12 @@
 /*! @{ */
 
 /*!
+ * \internal
+ * \brief Log a message about invalid attempt to access a type.
+ */
+void stasis_log_bad_type_access(const char *name);
+
+/*!
  * \brief Boiler-plate removing macro for defining message types.
  *
  * \param name Name of message type.
@@ -641,7 +647,9 @@
 #define STASIS_MESSAGE_TYPE_DEFN(name)				\
 	static struct stasis_message_type *_priv_ ## name;	\
 	struct stasis_message_type *name(void) {		\
-		ast_assert(_priv_ ## name != NULL);		\
+		if (_priv_ ## name == NULL) {			\
+			stasis_log_bad_type_access(#name);	\
+		}						\
 		return _priv_ ## name;				\
 	}
 
@@ -663,6 +671,15 @@
 /*!
  * \brief Boiler-plate removing macro for cleaning up message types.
  *
+ * Note that if your type is defined in core instead of a loadable module, you
+ * should call message type cleanup from an ast_register_cleanup() handler
+ * instead of an ast_register_atexit() handler.
+ *
+ * The reason is that during an immediate shutdown, loadable modules (which may
+ * refer to core message types) are not unloaded. While the atexit handlers are
+ * run, there's a window of time where a module subscription might reference a
+ * core message type after it's been cleaned up. Which is bad.
+ *
  * \param name Name of message type.
  * \since 12
  */

Modified: team/qwell/queue_events/include/asterisk/stasis_bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/include/asterisk/stasis_bridging.h?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/include/asterisk/stasis_bridging.h (original)
+++ team/qwell/queue_events/include/asterisk/stasis_bridging.h Fri May 31 10:25:01 2013
@@ -183,19 +183,6 @@
 
 /*!
  * \since 12
- * \brief Extracts the type field from a \ref ast_bridge_blob.
- *
- * Returned \c char* is still owned by \a obj
- *
- * \param obj Channel blob object.
- *
- * \retval Type field value from the blob.
- * \retval \c NULL on error.
- */
-const char *ast_bridge_blob_json_type(struct ast_bridge_blob *obj);
-
-/*!
- * \since 12
  * \brief Publish a bridge channel enter event
  *
  * \param bridge The bridge a channel entered
@@ -220,11 +207,6 @@
 struct ast_json *ast_bridge_snapshot_to_json(const struct ast_bridge_snapshot *snapshot);
 
 /*!
- * \brief Dispose of the stasis bridging topics and message types
- */
-void ast_stasis_bridging_shutdown(void);
-
-/*!
  * \brief Initialize the stasis bridging topic and message types
  * \retval 0 on success
  * \retval -1 on failure

Modified: team/qwell/queue_events/include/asterisk/stasis_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/include/asterisk/stasis_channels.h?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/include/asterisk/stasis_channels.h (original)
+++ team/qwell/queue_events/include/asterisk/stasis_channels.h Fri May 31 10:25:01 2013
@@ -104,6 +104,15 @@
 
 /*!
  * \since 12
+ * \brief A caching topic which caches \ref ast_channel_snapshot messages from
+ * ast_channel_events_all(void) and indexes them by name.
+ *
+ * \retval Topic for all channel events.
+ */
+struct stasis_caching_topic *ast_channel_topic_all_cached_by_name(void);
+
+/*!
+ * \since 12
  * \brief Message type for \ref ast_channel_snapshot.
  *
  * \retval Message type for \ref ast_channel_snapshot.
@@ -134,6 +143,18 @@
  * \retval NULL on error
  */
 struct ast_channel_snapshot *ast_channel_snapshot_get_latest(const char *uniqueid);
+
+/*!
+ * \since 12
+ * \brief Obtain the latest \ref ast_channel_snapshot from the \ref stasis cache. This is
+ * an ao2 object, so use \ref ao2_cleanup() to deallocate.
+ *
+ * \param name The channel's name
+ *
+ * \retval A \ref ast_channel_snapshot on success
+ * \retval NULL on error
+ */
+struct ast_channel_snapshot *ast_channel_snapshot_get_latest_by_name(const char *name);
 
 /*!
  * \since 12
@@ -151,27 +172,6 @@
  * \return \c NULL on error
  */
 struct stasis_message *ast_channel_blob_create(struct ast_channel *chan,
-	struct stasis_message_type *type, struct ast_json *blob);
-
-/*!
- * \since 12
- * \brief Creates a \ref ast_channel_blob message using the current cached
- * \ref ast_channel_snapshot for the passed in \ref ast_channel
- *
- * The given \a blob should be treated as immutable and not modified after it is
- * put into the message.
- *
- * \param chan Channel blob is associated with, or \c NULL for global/all channels.
- * \param type Message type for this blob.
- * \param blob JSON object representing the data, or \c NULL for no data. If
- *             \c NULL, ast_json_null() is put into the object.
- *
- * \param chan Channel blob is associated with
- * \param blob JSON object representing the data.
- * \return \ref ast_channel_blob message.
- * \return \c NULL on error
- */
-struct stasis_message *ast_channel_cached_blob_create(struct ast_channel *chan,
 	struct stasis_message_type *type, struct ast_json *blob);
 
 /*!
@@ -483,11 +483,6 @@
 	const struct ast_channel_snapshot *new_snapshot);
 
 /*!
- * \brief Dispose of the stasis channel topics and message types
- */
-void ast_stasis_channels_shutdown(void);
-
-/*!
  * \brief Initialize the stasis channel topic and message types
  */
 void ast_stasis_channels_init(void);

Modified: team/qwell/queue_events/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/main/app.c?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/main/app.c (original)
+++ team/qwell/queue_events/main/app.c Fri May 31 10:25:01 2013
@@ -2816,7 +2816,7 @@
 	return msg;
 }
 
-static void app_exit(void)
+static void app_cleanup(void)
 {
 	ao2_cleanup(mwi_topic_all);
 	mwi_topic_all = NULL;
@@ -2829,6 +2829,8 @@
 
 int app_init(void)
 {
+	ast_register_cleanup(app_cleanup);
+
 	if (STASIS_MESSAGE_TYPE_INIT(ast_mwi_state_type) != 0) {
 		return -1;
 	}
@@ -2848,7 +2850,6 @@
 		return -1;
 	}
 
-	ast_register_atexit(app_exit);
 	return 0;
 }
 

Modified: team/qwell/queue_events/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/queue_events/main/asterisk.c?view=diff&rev=390287&r1=390286&r2=390287
==============================================================================
--- team/qwell/queue_events/main/asterisk.c (original)
+++ team/qwell/queue_events/main/asterisk.c Fri May 31 10:25:01 2013
@@ -347,6 +347,7 @@
 
 struct ast_atexit {
 	void (*func)(void);
+	int is_cleanup;
 	AST_LIST_ENTRY(ast_atexit) list;
 };
 
@@ -1111,7 +1112,7 @@
 /*! \brief Initialize the system level items for \ref stasis */
 static int stasis_system_topic_init(void)
 {
-	ast_register_atexit(stasis_system_topic_cleanup);
+	ast_register_cleanup(stasis_system_topic_cleanup);
 
 	system_topic = stasis_topic_create("ast_system");
 	if (!system_topic) {
@@ -1125,58 +1126,22 @@
 	return 0;
 }
 
-/*!
- * \brief Publish a \ref system_status_type message over \ref stasis
- *
- * \param payload The JSON payload to send with the message
- */
-static void publish_system_message(const char *message_type, struct ast_json *obj)
-{
-	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_json_payload *, payload, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_json *, event_info, NULL, ast_json_unref);
-
-	if (!obj) {
-		return;
-	}
-
-	ast_json_ref(obj);
-	event_info = ast_json_pack("{s: s, s: i, s: o}",
-			"type", message_type,
-			"class_type", EVENT_FLAG_SYSTEM,
-			"event", obj);
-	if (!event_info) {
-		return;
-	}
-
-	payload = ast_json_payload_create(event_info);
-	if (!payload) {
-		return;
-	}
-

[... 746 lines stripped ...]



More information about the asterisk-commits mailing list