[asterisk-commits] dlee: branch dlee/stasis-cache-split r393859 - in /team/dlee/stasis-cache-spl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 8 17:06:17 CDT 2013


Author: dlee
Date: Mon Jul  8 17:06:14 2013
New Revision: 393859

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393859
Log:
More ripples

Modified:
    team/dlee/stasis-cache-split/apps/app_voicemail.c
    team/dlee/stasis-cache-split/apps/confbridge/confbridge_manager.c
    team/dlee/stasis-cache-split/channels/chan_dahdi.c
    team/dlee/stasis-cache-split/channels/chan_iax2.c
    team/dlee/stasis-cache-split/channels/chan_mgcp.c
    team/dlee/stasis-cache-split/channels/chan_sip.c
    team/dlee/stasis-cache-split/channels/chan_unistim.c
    team/dlee/stasis-cache-split/channels/sig_pri.c
    team/dlee/stasis-cache-split/main/app.c
    team/dlee/stasis-cache-split/main/cdr.c
    team/dlee/stasis-cache-split/main/cel.c
    team/dlee/stasis-cache-split/main/devicestate.c
    team/dlee/stasis-cache-split/main/manager_bridging.c
    team/dlee/stasis-cache-split/main/manager_channels.c
    team/dlee/stasis-cache-split/main/manager_endpoints.c
    team/dlee/stasis-cache-split/main/presencestate.c
    team/dlee/stasis-cache-split/main/stasis_bridging.c
    team/dlee/stasis-cache-split/res/res_sip_mwi.c
    team/dlee/stasis-cache-split/res/res_stasis.c
    team/dlee/stasis-cache-split/res/stasis/control.c
    team/dlee/stasis-cache-split/res/stasis_http/resource_bridges.c
    team/dlee/stasis-cache-split/res/stasis_http/resource_channels.c
    team/dlee/stasis-cache-split/res/stasis_http/resource_endpoints.c
    team/dlee/stasis-cache-split/tests/test_cel.c
    team/dlee/stasis-cache-split/tests/test_stasis.c
    team/dlee/stasis-cache-split/tests/test_stasis_endpoints.c

Modified: team/dlee/stasis-cache-split/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/apps/app_voicemail.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/apps/app_voicemail.c (original)
+++ team/dlee/stasis-cache-split/apps/app_voicemail.c Mon Jul  8 17:06:14 2013
@@ -12640,7 +12640,7 @@
 	mwi_sub_sub = stasis_subscribe(ast_mwi_topic_all(), mwi_event_cb, NULL);
 
 	if (mwi_sub_sub) {
-		struct ao2_container *cached = stasis_cache_dump(ast_mwi_topic_cached(), stasis_subscription_change_type());
+		struct ao2_container *cached = stasis_cache_dump(ast_mwi_state_cache(), stasis_subscription_change_type());
 		if (cached) {
 			ao2_callback(cached, OBJ_MULTIPLE | OBJ_NODATA, dump_cache, NULL);
 		}

Modified: team/dlee/stasis-cache-split/apps/confbridge/confbridge_manager.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/apps/confbridge/confbridge_manager.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/apps/confbridge/confbridge_manager.c (original)
+++ team/dlee/stasis-cache-split/apps/confbridge/confbridge_manager.c Mon Jul  8 17:06:14 2013
@@ -341,7 +341,7 @@
 	STASIS_MESSAGE_TYPE_INIT(confbridge_talking_type);
 
 	bridge_state_router = stasis_message_router_create(
-		stasis_caching_get_topic(ast_bridge_topic_all_cached()));
+		ast_bridge_topic_all_cached());
 
 	if (!bridge_state_router) {
 		return -1;
@@ -412,7 +412,7 @@
 	}
 
 	channel_state_router = stasis_message_router_create(
-		stasis_caching_get_topic(ast_channel_topic_all_cached()));
+		ast_channel_topic_all_cached());
 
 	if (!channel_state_router) {
 		manager_confbridge_shutdown();

Modified: team/dlee/stasis-cache-split/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/channels/chan_dahdi.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/channels/chan_dahdi.c (original)
+++ team/dlee/stasis-cache-split/channels/chan_dahdi.c Mon Jul  8 17:06:14 2013
@@ -5559,7 +5559,7 @@
 	}
 
 	ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
-	mwi_message = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
+	mwi_message = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 
 	if (mwi_message) {
 		struct ast_mwi_state *mwi_state = stasis_message_data(mwi_message);

Modified: team/dlee/stasis-cache-split/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/channels/chan_iax2.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/channels/chan_iax2.c (original)
+++ team/dlee/stasis-cache-split/channels/chan_iax2.c Mon Jul  8 17:06:14 2013
@@ -8796,7 +8796,7 @@
 			}
 
 			ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
-			msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
+			msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 
 			if (msg) {
 				struct ast_mwi_state *mwi_state = stasis_message_data(msg);

Modified: team/dlee/stasis-cache-split/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/channels/chan_mgcp.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/channels/chan_mgcp.c (original)
+++ team/dlee/stasis-cache-split/channels/chan_mgcp.c Mon Jul  8 17:06:14 2013
@@ -507,7 +507,7 @@
 
 	ast_str_set(&uniqueid, 0, "%s@%s", mbox, cntx);
 
-	msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
+	msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 
 	if (msg) {
 		struct ast_mwi_state *mwi_state = stasis_message_data(msg);

Modified: team/dlee/stasis-cache-split/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/channels/chan_sip.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/channels/chan_sip.c (original)
+++ team/dlee/stasis-cache-split/channels/chan_sip.c Mon Jul  8 17:06:14 2013
@@ -28348,7 +28348,7 @@
 		ast_str_reset(uniqueid);
 		ast_str_set(&uniqueid, 0, "%s@%s", mailbox->mailbox, S_OR(mailbox->context, "default"));
 
-		msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
+		msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 		if (!msg) {
 			continue;
 		}

Modified: team/dlee/stasis-cache-split/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/channels/chan_unistim.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/channels/chan_unistim.c (original)
+++ team/dlee/stasis-cache-split/channels/chan_unistim.c Mon Jul  8 17:06:14 2013
@@ -5500,7 +5500,7 @@
 
 	ast_str_set(&uniqueid, 0, "%s@%s", mailbox, context);
 
-	msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
+	msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 
 	if (msg) {
 		struct ast_mwi_state *mwi_state = stasis_message_data(msg);

Modified: team/dlee/stasis-cache-split/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/channels/sig_pri.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/channels/sig_pri.c (original)
+++ team/dlee/stasis-cache-split/channels/sig_pri.c Mon Jul  8 17:06:14 2013
@@ -8956,7 +8956,7 @@
 		ast_str_reset(uniqueid);
 		ast_str_set(&uniqueid, 0, "%s@%s", pri->mbox[idx].number, pri->mbox[idx].context);
 
-		msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
+		msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), ast_str_buffer(uniqueid));
 		if (!msg) {
 			/* No cached event for this mailbox. */
 			continue;

Modified: team/dlee/stasis-cache-split/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/app.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/main/app.c (original)
+++ team/dlee/stasis-cache-split/main/app.c Mon Jul  8 17:06:14 2013
@@ -88,6 +88,7 @@
  * @{ \brief Define \ref stasis topic objects for MWI
  */
 static struct stasis_topic *mwi_topic_all;
+static struct stasis_cache *mwi_state_cache;
 static struct stasis_caching_topic *mwi_topic_cached;
 static struct stasis_topic_pool *mwi_topic_pool;
 /* @} */
@@ -2696,9 +2697,14 @@
 	return mwi_topic_all;
 }
 
-struct stasis_caching_topic *ast_mwi_topic_cached(void)
-{
-	return mwi_topic_cached;
+struct stasis_cache *ast_mwi_state_cache(void)
+{
+	return mwi_state_cache;
+}
+
+struct stasis_topic *ast_mwi_topic_cached(void)
+{
+	return stasis_caching_get_topic(mwi_topic_cached);
 }
 
 struct stasis_topic *ast_mwi_topic(const char *uniqueid)
@@ -2754,7 +2760,7 @@
 
 	if (!ast_strlen_zero(channel_id)) {
 		RAII_VAR(struct stasis_message *, chan_message,
-			stasis_cache_get(ast_channel_topic_all_cached(),
+			stasis_cache_get(ast_channel_cache(),
 					ast_channel_snapshot_type(),
 					channel_id),
 			ao2_cleanup);
@@ -2855,7 +2861,12 @@
 	if (!mwi_topic_all) {
 		return -1;
 	}
-	mwi_topic_cached = stasis_caching_topic_create(mwi_topic_all, mwi_state_get_id);
+	mwi_state_cache = stasis_cache_create(mwi_state_get_id);
+	if (!mwi_state_cache) {
+		return -1;
+	}
+	mwi_topic_cached = stasis_caching_topic_create(mwi_topic_all,
+		mwi_state_cache);
 	if (!mwi_topic_cached) {
 		return -1;
 	}

Modified: team/dlee/stasis-cache-split/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/cdr.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/main/cdr.c (original)
+++ team/dlee/stasis-cache-split/main/cdr.c Mon Jul  8 17:06:14 2013
@@ -4017,11 +4017,11 @@
 		return -1;
 	}
 
-	channel_subscription = stasis_forward_all(stasis_caching_get_topic(ast_channel_topic_all_cached()), cdr_topic);
+	channel_subscription = stasis_forward_all(ast_channel_topic_all_cached(), cdr_topic);
 	if (!channel_subscription) {
 		return -1;
 	}
-	bridge_subscription = stasis_forward_all(stasis_caching_get_topic(ast_bridge_topic_all_cached()), cdr_topic);
+	bridge_subscription = stasis_forward_all(ast_bridge_topic_all_cached(), cdr_topic);
 	if (!bridge_subscription) {
 		return -1;
 	}

Modified: team/dlee/stasis-cache-split/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/cel.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/main/cel.c (original)
+++ team/dlee/stasis-cache-split/main/cel.c Mon Jul  8 17:06:14 2013
@@ -1463,14 +1463,14 @@
 	}
 
 	cel_channel_forwarder = stasis_forward_all(
-		stasis_caching_get_topic(ast_channel_topic_all_cached()),
+		ast_channel_topic_all_cached(),
 		cel_aggregation_topic);
 	if (!cel_channel_forwarder) {
 		return -1;
 	}
 
 	cel_bridge_forwarder = stasis_forward_all(
-		stasis_caching_get_topic(ast_bridge_topic_all_cached()),
+		ast_bridge_topic_all_cached(),
 		cel_aggregation_topic);
 	if (!cel_bridge_forwarder) {
 		return -1;

Modified: team/dlee/stasis-cache-split/main/devicestate.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/devicestate.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/main/devicestate.c (original)
+++ team/dlee/stasis-cache-split/main/devicestate.c Mon Jul  8 17:06:14 2013
@@ -196,6 +196,7 @@
 struct stasis_subscription *devstate_message_sub;
 
 static struct stasis_topic *device_state_topic_all;
+static struct stasis_cache *device_state_cache;
 static struct stasis_caching_topic *device_state_topic_cached;
 static struct stasis_topic_pool *device_state_topic_pool;
 
@@ -285,7 +286,7 @@
 	RAII_VAR(struct stasis_message *, cached_msg, NULL, ao2_cleanup);
 	struct ast_device_state_message *device_state;
 
-	cached_msg = stasis_cache_get(ast_device_state_topic_cached(), ast_device_state_message_type(), device);
+	cached_msg = stasis_cache_get(ast_device_state_cache(), ast_device_state_message_type(), device);
 	if (!cached_msg) {
 		return AST_DEVICE_UNKNOWN;
 	}
@@ -586,7 +587,7 @@
 
 	ast_devstate_aggregate_init(&aggregate);
 
-	cached = stasis_cache_dump(ast_device_state_topic_cached(), NULL);
+	cached = stasis_cache_dump(ast_device_state_cache(), NULL);
 
 	ao2_callback_data(cached, OBJ_NODATA, devstate_change_aggregator_cb, &aggregate, device);
 
@@ -598,7 +599,7 @@
 	RAII_VAR(struct stasis_message *, cached_aggregate_msg, NULL, ao2_cleanup);
 	struct ast_device_state_message *cached_aggregate_device_state;
 
-	cached_aggregate_msg = stasis_cache_get(ast_device_state_topic_cached(), ast_device_state_message_type(), device);
+	cached_aggregate_msg = stasis_cache_get(ast_device_state_cache(), ast_device_state_message_type(), device);
 	if (!cached_aggregate_msg) {
 		return 1;
 	}
@@ -719,9 +720,14 @@
 	return device_state_topic_all;
 }
 
-struct stasis_caching_topic *ast_device_state_topic_cached(void)
-{
-	return device_state_topic_cached;
+struct stasis_cache *ast_device_state_cache(void)
+{
+	return device_state_cache;
+}
+
+struct stasis_topic *ast_device_state_topic_cached(void)
+{
+	return stasis_caching_get_topic(device_state_topic_cached);
 }
 
 struct stasis_topic *ast_device_state_topic(const char *device)
@@ -794,7 +800,11 @@
 	if (!device_state_topic_all) {
 		return -1;
 	}
-	device_state_topic_cached = stasis_caching_topic_create(device_state_topic_all, device_state_get_id);
+	device_state_cache = stasis_cache_create(device_state_get_id);
+	if (!device_state_cache) {
+		return -1;
+	}
+	device_state_topic_cached = stasis_caching_topic_create(device_state_topic_all, device_state_cache);
 	if (!device_state_topic_cached) {
 		return -1;
 	}
@@ -803,7 +813,7 @@
 		return -1;
 	}
 
-	devstate_message_sub = stasis_subscribe(stasis_caching_get_topic(ast_device_state_topic_cached()), devstate_change_collector_cb, NULL);
+	devstate_message_sub = stasis_subscribe(ast_device_state_topic_cached(), devstate_change_collector_cb, NULL);
 
 	if (!devstate_message_sub) {
 		ast_log(LOG_ERROR, "Failed to create subscription for the device state change collector\n");

Modified: team/dlee/stasis-cache-split/main/manager_bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/manager_bridging.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/main/manager_bridging.c (original)
+++ team/dlee/stasis-cache-split/main/manager_bridging.c Mon Jul  8 17:06:14 2013
@@ -327,7 +327,7 @@
 		ast_str_set(&id_text, 0, "ActionID: %s\r\n", id);
 	}
 
-	bridges = stasis_cache_dump(ast_bridge_topic_all_cached(), ast_bridge_snapshot_type());
+	bridges = stasis_cache_dump(ast_bridge_cache(), ast_bridge_snapshot_type());
 	if (!bridges) {
 		astman_send_error(s, m, "Internal error");
 		return -1;
@@ -390,7 +390,7 @@
 		ast_str_set(&id_text, 0, "ActionID: %s\r\n", id);
 	}
 
-	msg = stasis_cache_get(ast_bridge_topic_all_cached(), ast_bridge_snapshot_type(), bridge_uniqueid);
+	msg = stasis_cache_get(ast_bridge_cache(), ast_bridge_snapshot_type(), bridge_uniqueid);
 	if (!msg) {
 		astman_send_error(s, m, "Specified BridgeUniqueid not found");
 		return -1;
@@ -447,7 +447,7 @@
 		return -1;
 	}
 
-	bridge_topic = stasis_caching_get_topic(ast_bridge_topic_all_cached());
+	bridge_topic = ast_bridge_topic_all_cached();
 	if (!bridge_topic) {
 		return -1;
 	}

Modified: team/dlee/stasis-cache-split/main/manager_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/manager_channels.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/main/manager_channels.c (original)
+++ team/dlee/stasis-cache-split/main/manager_channels.c Mon Jul  8 17:06:14 2013
@@ -1254,7 +1254,7 @@
 	if (!message_router) {
 		return -1;
 	}
-	channel_topic = stasis_caching_get_topic(ast_channel_topic_all_cached());
+	channel_topic = ast_channel_topic_all_cached();
 	if (!channel_topic) {
 		return -1;
 	}

Modified: team/dlee/stasis-cache-split/main/manager_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/manager_endpoints.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/main/manager_endpoints.c (original)
+++ team/dlee/stasis-cache-split/main/manager_endpoints.c Mon Jul  8 17:06:14 2013
@@ -49,7 +49,7 @@
 	struct stasis_topic *topic,
 	struct stasis_message *message)
 {
-	stasis_forward_message(ast_manager_get_topic(), stasis_caching_get_topic(ast_endpoint_topic_all_cached()), message);
+	stasis_forward_message(ast_manager_get_topic(), ast_endpoint_topic_all_cached(), message);
 }
 
 int manager_endpoints_init(void)
@@ -64,7 +64,7 @@
 
 	ast_register_atexit(manager_endpoints_shutdown);
 
-	endpoint_topic = stasis_caching_get_topic(ast_endpoint_topic_all_cached());
+	endpoint_topic = ast_endpoint_topic_all_cached();
 	if (!endpoint_topic) {
 		return -1;
 	}

Modified: team/dlee/stasis-cache-split/main/presencestate.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/presencestate.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/main/presencestate.c (original)
+++ team/dlee/stasis-cache-split/main/presencestate.c Mon Jul  8 17:06:14 2013
@@ -54,8 +54,9 @@
 };
 
 STASIS_MESSAGE_TYPE_DEFN(ast_presence_state_message_type);
-struct stasis_topic *presence_state_topic_all;
-struct stasis_caching_topic *presence_state_topic_cached;
+static struct stasis_topic *presence_state_topic_all;
+static struct stasis_cache *presence_state_cache;
+static struct stasis_caching_topic *presence_state_topic_cached;
 
 /*! \brief  A presence state provider */
 struct presence_state_provider {
@@ -95,7 +96,7 @@
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
 	struct ast_presence_state_message *presence_state;
 
-	msg = stasis_cache_get(ast_presence_state_topic_cached(), ast_presence_state_message_type(), presence_provider);
+	msg = stasis_cache_get(ast_presence_state_cache(), ast_presence_state_message_type(), presence_provider);
 
 	if (!msg) {
 		return res;
@@ -294,9 +295,14 @@
 	return presence_state_topic_all;
 }
 
-struct stasis_caching_topic *ast_presence_state_topic_cached(void)
-{
-	return presence_state_topic_cached;
+struct stasis_cache *ast_presence_state_cache(void)
+{
+	return presence_state_cache;
+}
+
+struct stasis_topic *ast_presence_state_topic_cached(void)
+{
+	return stasis_caching_get_topic(presence_state_topic_cached);
 }
 
 static const char *presence_state_get_id(struct stasis_message *msg)
@@ -331,7 +337,12 @@
 		return -1;
 	}
 
-	presence_state_topic_cached = stasis_caching_topic_create(presence_state_topic_all, presence_state_get_id);
+	presence_state_cache = stasis_cache_create(presence_state_get_id);
+	if (!presence_state_cache) {
+		return -1;
+	}
+
+	presence_state_topic_cached = stasis_caching_topic_create(presence_state_topic_all, presence_state_cache);
 	if (!presence_state_topic_cached) {
 		return -1;
 	}

Modified: team/dlee/stasis-cache-split/main/stasis_bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/main/stasis_bridging.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/main/stasis_bridging.c (original)
+++ team/dlee/stasis-cache-split/main/stasis_bridging.c Mon Jul  8 17:06:14 2013
@@ -370,8 +370,11 @@
 /*! \brief Aggregate topic for bridge messages */
 static struct stasis_topic *bridge_topic_all;
 
+/*! \brief Cache for bridge snapshots */
+struct stasis_cache *bridge_cache;
+
 /*! \brief Caching aggregate topic for bridge snapshots */
-static struct stasis_caching_topic *bridge_topic_all_cached;
+static struct stasis_topic *bridge_topic_all_cached;
 
 /*! \brief Topic pool for individual bridge topics */
 static struct stasis_topic_pool *bridge_topic_pool;
@@ -429,14 +432,27 @@
 	return bridge_topic;
 }
 
+struct stasis_topic *ast_bridge_topic_cached(struct ast_bridge *bridge)
+{
+	struct stasis_topic *bridge_topic = stasis_topic_pool_get_topic(bridge_topic_pool, bridge->uniqueid);
+	if (!bridge_topic) {
+		return ast_bridge_topic_all_cached();
+	}
+	return bridge_topic;
+}
 struct stasis_topic *ast_bridge_topic_all(void)
 {
 	return bridge_topic_all;
 }
 
-struct stasis_caching_topic *ast_bridge_topic_all_cached(void)
-{
-	return bridge_topic_all_cached;
+struct stasis_cache *ast_bridge_cache(void)
+{
+	return bridge_cache;
+}
+
+struct stasis_topic *ast_bridge_topic_all_cached(void)
+{
+	return stasis_caching_get_topic(bridge_topic_all_cached);
 }
 
 void ast_bridge_publish_state(struct ast_bridge *bridge)
@@ -1000,7 +1016,7 @@
 
 	ast_assert(!ast_strlen_zero(uniqueid));
 
-	message = stasis_cache_get(ast_bridge_topic_all_cached(),
+	message = stasis_cache_get(ast_bridge_cache(),
 			ast_bridge_snapshot_type(),
 			uniqueid);
 	if (!message) {
@@ -1054,10 +1070,11 @@
 	STASIS_MESSAGE_TYPE_INIT(ast_blind_transfer_type);
 	STASIS_MESSAGE_TYPE_INIT(ast_attended_transfer_type);
 	bridge_topic_all = stasis_topic_create("ast_bridge_topic_all");
-	bridge_topic_all_cached = stasis_caching_topic_create(bridge_topic_all, bridge_snapshot_get_id);
+	bridge_cache = stasis_cache_create(bridge_snapshot_get_id);
+	bridge_topic_all_cached = stasis_topic_create("ast_bridge_topic_all_cached");
 	bridge_topic_pool = stasis_topic_pool_create(bridge_topic_all);
 
 	return !bridge_topic_all
-		|| !bridge_topic_all_cached
+		|| !bridge_cached
 		|| !bridge_topic_pool ? -1 : 0;
 }

Modified: team/dlee/stasis-cache-split/res/res_sip_mwi.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/res/res_sip_mwi.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/res/res_sip_mwi.c (original)
+++ team/dlee/stasis-cache-split/res/res_sip_mwi.c Mon Jul  8 17:06:14 2013
@@ -239,7 +239,7 @@
 	struct message_accumulator *counter = arg;
 	struct ast_mwi_state *mwi_state;
 
-	msg = stasis_cache_get(ast_mwi_topic_cached(), ast_mwi_state_type(), mwi_stasis->mailbox);
+	msg = stasis_cache_get(ast_mwi_state_cache(), ast_mwi_state_type(), mwi_stasis->mailbox);
 	if (!msg) {
 		return 0;
 	}

Modified: team/dlee/stasis-cache-split/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/res/res_stasis.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/res/res_stasis.c (original)
+++ team/dlee/stasis-cache-split/res/res_stasis.c Mon Jul  8 17:06:14 2013
@@ -940,7 +940,8 @@
 		return AST_MODULE_LOAD_FAILURE;
 	}
 
-	channel_router = stasis_message_router_create(stasis_caching_get_topic(ast_channel_topic_all_cached()));
+	channel_router = stasis_message_router_create(
+		ast_channel_topic_all_cached());
 	if (!channel_router) {
 		return AST_MODULE_LOAD_FAILURE;
 	}
@@ -960,7 +961,8 @@
 		return AST_MODULE_LOAD_FAILURE;
 	}
 
-	bridge_router = stasis_message_router_create(stasis_caching_get_topic(ast_bridge_topic_all_cached()));
+	bridge_router = stasis_message_router_create(
+		ast_bridge_topic_all_cached());
 	if (!bridge_router) {
 		return AST_MODULE_LOAD_FAILURE;
 	}

Modified: team/dlee/stasis-cache-split/res/stasis/control.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/res/stasis/control.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/res/stasis/control.c (original)
+++ team/dlee/stasis-cache-split/res/stasis/control.c Mon Jul  8 17:06:14 2013
@@ -237,13 +237,13 @@
 	const struct stasis_app_control *control)
 {
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-	struct stasis_caching_topic *caching_topic;
+	struct stasis_cache *cache;
 	struct ast_channel_snapshot *snapshot;
 
-	caching_topic = ast_channel_topic_all_cached();
-	ast_assert(caching_topic != NULL);
-
-	msg = stasis_cache_get(caching_topic, ast_channel_snapshot_type(),
+	cache = ast_channel_cache();
+	ast_assert(cache != NULL);
+
+	msg = stasis_cache_get(cache, ast_channel_snapshot_type(),
 		stasis_app_control_get_channel_id(control));
 	if (!msg) {
 		return NULL;

Modified: team/dlee/stasis-cache-split/res/stasis_http/resource_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/res/stasis_http/resource_bridges.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/res/stasis_http/resource_bridges.c (original)
+++ team/dlee/stasis-cache-split/res/stasis_http/resource_bridges.c Mon Jul  8 17:06:14 2013
@@ -176,22 +176,22 @@
 
 void stasis_http_get_bridges(struct ast_variable *headers, struct ast_get_bridges_args *args, struct stasis_http_response *response)
 {
-	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct ao2_container *, snapshots, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
 	struct ao2_iterator i;
 	void *obj;
 
-	caching_topic = ast_bridge_topic_all_cached();
-	if (!caching_topic) {
+	cache = ast_bridge_cache();
+	if (!cache) {
 		stasis_http_response_error(
 			response, 500, "Internal Server Error",
 			"Message bus not initialized");
 		return;
 	}
-	ao2_ref(caching_topic, +1);
-
-	snapshots = stasis_cache_dump(caching_topic, ast_bridge_snapshot_type());
+	ao2_ref(cache, +1);
+
+	snapshots = stasis_cache_dump(cache, ast_bridge_snapshot_type());
 	if (!snapshots) {
 		stasis_http_response_alloc_failed(response);
 		return;

Modified: team/dlee/stasis-cache-split/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/res/stasis_http/resource_channels.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/res/stasis_http/resource_channels.c (original)
+++ team/dlee/stasis-cache-split/res/stasis_http/resource_channels.c Mon Jul  8 17:06:14 2013
@@ -388,18 +388,18 @@
 			     struct stasis_http_response *response)
 {
 	RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-	struct stasis_caching_topic *caching_topic;
+	struct stasis_cache *cache;
 	struct ast_channel_snapshot *snapshot;
 
-	caching_topic = ast_channel_topic_all_cached();
-	if (!caching_topic) {
+	cache = ast_channel_cache();
+	if (!cache) {
 		stasis_http_response_error(
 			response, 500, "Internal Server Error",
 			"Message bus not initialized");
 		return;
 	}
 
-	msg = stasis_cache_get(caching_topic, ast_channel_snapshot_type(),
+	msg = stasis_cache_get(cache, ast_channel_snapshot_type(),
 			       args->channel_id);
 	if (!msg) {
 		stasis_http_response_error(
@@ -438,22 +438,22 @@
 			      struct ast_get_channels_args *args,
 			      struct stasis_http_response *response)
 {
-	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct ao2_container *, snapshots, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
 	struct ao2_iterator i;
 	void *obj;
 
-	caching_topic = ast_channel_topic_all_cached();
-	if (!caching_topic) {
+	cache = ast_channel_cache();
+	if (!cache) {
 		stasis_http_response_error(
 			response, 500, "Internal Server Error",
 			"Message bus not initialized");
 		return;
 	}
-	ao2_ref(caching_topic, +1);
-
-	snapshots = stasis_cache_dump(caching_topic, ast_channel_snapshot_type());
+	ao2_ref(cache, +1);
+
+	snapshots = stasis_cache_dump(cache, ast_channel_snapshot_type());
 	if (!snapshots) {
 		stasis_http_response_alloc_failed(response);
 		return;

Modified: team/dlee/stasis-cache-split/res/stasis_http/resource_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/res/stasis_http/resource_endpoints.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/res/stasis_http/resource_endpoints.c (original)
+++ team/dlee/stasis-cache-split/res/stasis_http/resource_endpoints.c Mon Jul  8 17:06:14 2013
@@ -37,22 +37,22 @@
 	struct ast_get_endpoints_args *args,
 	struct stasis_http_response *response)
 {
-	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct ao2_container *, snapshots, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
 	struct ao2_iterator i;
 	void *obj;
 
-	caching_topic = ast_endpoint_topic_all_cached();
-	if (!caching_topic) {
+	cache = ast_endpoint_cache();
+	if (!cache) {
 		stasis_http_response_error(
 			response, 500, "Internal Server Error",
 			"Message bus not initialized");
 		return;
 	}
-	ao2_ref(caching_topic, +1);
+	ao2_ref(cache, +1);
 
-	snapshots = stasis_cache_dump(caching_topic, ast_endpoint_snapshot_type());
+	snapshots = stasis_cache_dump(cache, ast_endpoint_snapshot_type());
 	if (!snapshots) {
 		stasis_http_response_alloc_failed(response);
 		return;
@@ -83,7 +83,7 @@
 	struct ast_get_endpoints_by_tech_args *args,
 	struct stasis_http_response *response)
 {
-	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct ao2_container *, snapshots, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
 	struct ao2_iterator i;
@@ -91,16 +91,16 @@
 
 	/* TODO - if tech isn't a recognized type of endpoint, it should 404 */
 
-	caching_topic = ast_endpoint_topic_all_cached();
-	if (!caching_topic) {
+	cache = ast_endpoint_cache();
+	if (!cache) {
 		stasis_http_response_error(
 			response, 500, "Internal Server Error",
 			"Message bus not initialized");
 		return;
 	}
-	ao2_ref(caching_topic, +1);
+	ao2_ref(cache, +1);
 
-	snapshots = stasis_cache_dump(caching_topic, ast_endpoint_snapshot_type());
+	snapshots = stasis_cache_dump(cache, ast_endpoint_snapshot_type());
 	if (!snapshots) {
 		stasis_http_response_alloc_failed(response);
 		return;

Modified: team/dlee/stasis-cache-split/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/tests/test_cel.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/tests/test_cel.c (original)
+++ team/dlee/stasis-cache-split/tests/test_cel.c Mon Jul  8 17:06:14 2013
@@ -145,14 +145,14 @@
 	if (!ast_hangup((channel))) { \
 		APPEND_EVENT(channel, AST_CEL_HANGUP, NULL, hangup_extra, NULL); \
 		APPEND_EVENT(channel, AST_CEL_CHANNEL_END, NULL, NULL, NULL); \
-		ao2_cleanup(stasis_cache_get_extended(ast_channel_topic_all_cached(), \
+		ao2_cleanup(stasis_cache_get_extended(ast_channel_cache(), \
 			ast_channel_snapshot_type(), ast_channel_uniqueid(channel), 1)); \
 		ao2_cleanup(channel); \
 		channel = NULL; \
 	} else { \
 		APPEND_EVENT(channel, AST_CEL_HANGUP, NULL, hangup_extra, NULL); \
 		APPEND_EVENT(channel, AST_CEL_CHANNEL_END, NULL, NULL, NULL); \
-		ao2_cleanup(stasis_cache_get_extended(ast_channel_topic_all_cached(), \
+		ao2_cleanup(stasis_cache_get_extended(ast_channel_cache(), \
 			ast_channel_snapshot_type(), ast_channel_uniqueid(channel), 1)); \
 		ao2_cleanup(channel); \
 	} \

Modified: team/dlee/stasis-cache-split/tests/test_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/tests/test_stasis.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/tests/test_stasis.c (original)
+++ team/dlee/stasis-cache-split/tests/test_stasis.c Mon Jul  8 17:06:14 2013
@@ -614,6 +614,7 @@
 {
 	RAII_VAR(struct stasis_message_type *, non_cache_type, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, stasis_caching_unsubscribe);
 	RAII_VAR(struct consumer *, consumer, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_subscription *, sub, NULL, stasis_unsubscribe);
@@ -636,7 +637,9 @@
 	ast_test_validate(test, NULL != non_cache_type);
 	topic = stasis_topic_create("SomeTopic");
 	ast_test_validate(test, NULL != topic);
-	caching_topic = stasis_caching_topic_create(topic, cache_test_data_id);
+	cache = stasis_cache_create(cache_test_data_id);
+	ast_test_validate(test, NULL != cache);
+	caching_topic = stasis_caching_topic_create(topic, cache);
 	ast_test_validate(test, NULL != caching_topic);
 	consumer = consumer_create(1);
 	ast_test_validate(test, NULL != consumer);
@@ -664,6 +667,7 @@
 {
 	RAII_VAR(struct stasis_message_type *, cache_type, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, stasis_caching_unsubscribe);
 	RAII_VAR(struct consumer *, consumer, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_subscription *, sub, NULL, stasis_unsubscribe);
@@ -689,7 +693,9 @@
 	ast_test_validate(test, NULL != cache_type);
 	topic = stasis_topic_create("SomeTopic");
 	ast_test_validate(test, NULL != topic);
-	caching_topic = stasis_caching_topic_create(topic, cache_test_data_id);
+	cache = stasis_cache_create(cache_test_data_id);
+	ast_test_validate(test, NULL != cache);
+	caching_topic = stasis_caching_topic_create(topic, cache);
 	ast_test_validate(test, NULL != caching_topic);
 	consumer = consumer_create(1);
 	ast_test_validate(test, NULL != consumer);
@@ -714,7 +720,7 @@
 	ast_test_validate(test, topic == actual_update->topic);
 	ast_test_validate(test, NULL == actual_update->old_snapshot);
 	ast_test_validate(test, test_message1_1 == actual_update->new_snapshot);
-	ast_test_validate(test, test_message1_1 == stasis_cache_get(caching_topic, cache_type, "1"));
+	ast_test_validate(test, test_message1_1 == stasis_cache_get(cache, cache_type, "1"));
 	/* stasis_cache_get returned a ref, so unref test_message1_1 */
 	ao2_ref(test_message1_1, -1);
 
@@ -723,7 +729,7 @@
 	ast_test_validate(test, topic == actual_update->topic);
 	ast_test_validate(test, NULL == actual_update->old_snapshot);
 	ast_test_validate(test, test_message2_1 == actual_update->new_snapshot);
-	ast_test_validate(test, test_message2_1 == stasis_cache_get(caching_topic, cache_type, "2"));
+	ast_test_validate(test, test_message2_1 == stasis_cache_get(cache, cache_type, "2"));
 	/* stasis_cache_get returned a ref, so unref test_message2_1 */
 	ao2_ref(test_message2_1, -1);
 
@@ -739,7 +745,7 @@
 	ast_test_validate(test, topic == actual_update->topic);
 	ast_test_validate(test, test_message2_1 == actual_update->old_snapshot);
 	ast_test_validate(test, test_message2_2 == actual_update->new_snapshot);
-	ast_test_validate(test, test_message2_2 == stasis_cache_get(caching_topic, cache_type, "2"));
+	ast_test_validate(test, test_message2_2 == stasis_cache_get(cache, cache_type, "2"));
 	/* stasis_cache_get returned a ref, so unref test_message2_2 */
 	ao2_ref(test_message2_2, -1);
 
@@ -755,7 +761,7 @@
 	ast_test_validate(test, topic == actual_update->topic);
 	ast_test_validate(test, test_message1_1 == actual_update->old_snapshot);
 	ast_test_validate(test, NULL == actual_update->new_snapshot);
-	ast_test_validate(test, NULL == stasis_cache_get(caching_topic, cache_type, "1"));
+	ast_test_validate(test, NULL == stasis_cache_get(cache, cache_type, "1"));
 
 	return AST_TEST_PASS;
 }
@@ -764,6 +770,7 @@
 {
 	RAII_VAR(struct stasis_message_type *, cache_type, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, stasis_caching_unsubscribe);
 	RAII_VAR(struct consumer *, consumer, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_subscription *, sub, NULL, stasis_unsubscribe);
@@ -791,7 +798,9 @@
 	ast_test_validate(test, NULL != cache_type);
 	topic = stasis_topic_create("SomeTopic");
 	ast_test_validate(test, NULL != topic);
-	caching_topic = stasis_caching_topic_create(topic, cache_test_data_id);
+	cache = stasis_cache_create(cache_test_data_id);
+	ast_test_validate(test, NULL != cache);
+	caching_topic = stasis_caching_topic_create(topic, cache);
 	ast_test_validate(test, NULL != caching_topic);
 	consumer = consumer_create(1);
 	ast_test_validate(test, NULL != consumer);
@@ -811,7 +820,7 @@
 	ast_test_validate(test, 2 == actual_len);
 
 	/* Check the cache */
-	cache_dump = stasis_cache_dump(caching_topic, NULL);
+	cache_dump = stasis_cache_dump(cache, NULL);
 	ast_test_validate(test, NULL != cache_dump);
 	ast_test_validate(test, 2 == ao2_container_count(cache_dump));
 	i = ao2_iterator_init(cache_dump, 0);
@@ -829,7 +838,7 @@
 	ast_test_validate(test, 3 == actual_len);
 
 	/* Check the cache */
-	cache_dump = stasis_cache_dump(caching_topic, NULL);
+	cache_dump = stasis_cache_dump(cache, NULL);
 	ast_test_validate(test, NULL != cache_dump);
 	ast_test_validate(test, 2 == ao2_container_count(cache_dump));
 	i = ao2_iterator_init(cache_dump, 0);
@@ -847,7 +856,7 @@
 	ast_test_validate(test, 4 == actual_len);
 
 	/* Check the cache */
-	cache_dump = stasis_cache_dump(caching_topic, NULL);
+	cache_dump = stasis_cache_dump(cache, NULL);
 	ast_test_validate(test, NULL != cache_dump);
 	ast_test_validate(test, 1 == ao2_container_count(cache_dump));
 	i = ao2_iterator_init(cache_dump, 0);
@@ -858,7 +867,7 @@
 
 	/* Dump the cache to ensure that it has no subscription change items in it since those aren't cached */
 	ao2_cleanup(cache_dump);
-	cache_dump = stasis_cache_dump(caching_topic, stasis_subscription_change_type());
+	cache_dump = stasis_cache_dump(cache, stasis_subscription_change_type());
 	ast_test_validate(test, 0 == ao2_container_count(cache_dump));
 
 	return AST_TEST_PASS;

Modified: team/dlee/stasis-cache-split/tests/test_stasis_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-cache-split/tests/test_stasis_endpoints.c?view=diff&rev=393859&r1=393858&r2=393859
==============================================================================
--- team/dlee/stasis-cache-split/tests/test_stasis_endpoints.c (original)
+++ team/dlee/stasis-cache-split/tests/test_stasis_endpoints.c Mon Jul  8 17:06:14 2013
@@ -160,7 +160,7 @@
 	ast_test_validate(test, NULL != sink);
 
 	sub = stasis_subscribe(
-		stasis_caching_get_topic(ast_endpoint_topic_all_cached()),
+		ast_endpoint_topic_all_cached(),
 		stasis_message_sink_cb(), sink);
 	ast_test_validate(test, NULL != sub);
 




More information about the asterisk-commits mailing list