[asterisk-commits] dlee: branch dlee/tp-local r399780 - /team/dlee/tp-local/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 25 13:19:02 CDT 2013
Author: dlee
Date: Wed Sep 25 13:18:59 2013
New Revision: 399780
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399780
Log:
What if we didn't pass along the topic?
Modified:
team/dlee/tp-local/main/stasis.c
team/dlee/tp-local/main/stasis_cache.c
Modified: team/dlee/tp-local/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/tp-local/main/stasis.c?view=diff&rev=399780&r1=399779&r2=399780
==============================================================================
--- team/dlee/tp-local/main/stasis.c (original)
+++ team/dlee/tp-local/main/stasis.c Wed Sep 25 13:18:59 2013
@@ -491,46 +491,6 @@
}
/*!
- * \internal
- * \brief Information needed to dispatch a message to a subscription
- */
-struct dispatch {
- /*! Topic message was published to */
- struct stasis_topic *topic;
- /*! The message itself */
- struct stasis_message *message;
-};
-
-static void dispatch_dtor(void *obj)
-{
- struct dispatch *dispatch = obj;
-
- ao2_cleanup(dispatch->topic);
- ao2_cleanup(dispatch->message);
-}
-
-static struct dispatch *dispatch_create(struct stasis_topic *topic, struct stasis_message *message)
-{
- struct dispatch *dispatch;
-
- ast_assert(topic != NULL);
- ast_assert(message != NULL);
-
- dispatch = ao2_alloc(sizeof(*dispatch), dispatch_dtor);
- if (!dispatch) {
- return NULL;
- }
-
- dispatch->topic = topic;
- ao2_ref(topic, +1);
-
- dispatch->message = message;
- ao2_ref(message, +1);
-
- return dispatch;
-}
-
-/*!
* \brief Dispatch a message to a subscriber
* \param data \ref dispatch object
* \return 0
@@ -538,45 +498,27 @@
static int dispatch_exec(struct ast_taskprocessor_local *local)
{
struct stasis_subscription *sub = local->local_data;
- struct dispatch *dispatch = local->data;
-
- subscription_invoke(sub, dispatch->topic, dispatch->message);
- ao2_cleanup(dispatch);
+ struct stasis_message *message = local->data;
+
+ subscription_invoke(sub, NULL, message);
+ ao2_cleanup(message);
return 0;
}
static void dispatch_message(struct stasis_subscription *sub,
- struct dispatch *dispatch)
+ struct stasis_message *message)
{
if (sub->mailbox) {
- ao2_bump(dispatch);
- if (ast_taskprocessor_push_local(sub->mailbox, dispatch_exec, dispatch) != 0) {
+ ao2_bump(message);
+ if (ast_taskprocessor_push_local(sub->mailbox, dispatch_exec, message) != 0) {
/* Push failed; ugh. */
ast_log(LOG_DEBUG, "Dropping dispatch\n");
- ao2_cleanup(dispatch);
+ ao2_cleanup(message);
}
} else {
/* Dispatch directly */
- subscription_invoke(sub, dispatch->topic, dispatch->message);
- }
-}
-
-static void dispatch_single_message(struct stasis_subscription *sub,
- struct stasis_topic *publisher_topic, struct stasis_message *message)
-{
- if (sub->mailbox) {
- RAII_VAR(struct dispatch *, dispatch, NULL, ao2_cleanup);
- dispatch = dispatch_create(publisher_topic, message);
- if (!dispatch) {
- ast_log(LOG_DEBUG, "Dropping dispatch\n");
- return;
- }
-
- dispatch_message(sub, dispatch);
- } else {
- /* Dispatch directly */
- subscription_invoke(sub, publisher_topic, message);
+ subscription_invoke(sub, NULL, message);
}
}
@@ -587,7 +529,6 @@
* Make sure we hold onto a reference while dispatching. */
RAII_VAR(struct stasis_topic *, topic, ao2_bump(_topic),
ao2_cleanup);
- RAII_VAR(struct dispatch *, dispatch, NULL, ao2_cleanup);
SCOPED_AO2LOCK(lock, topic);
ast_assert(topic != NULL);
@@ -598,18 +539,12 @@
return;
}
- dispatch = dispatch_create(publisher_topic, message);
- if (!dispatch) {
- ast_log(LOG_DEBUG, "Dropping dispatch\n");
- return;
- }
-
for (i = 0; i < ast_vector_size(topic->subscribers); ++i) {
struct stasis_subscription *sub = ast_vector_get(topic->subscribers, i);
ast_assert(sub != NULL);
- dispatch_message(sub, dispatch);
+ dispatch_message(sub, message);
}
}
@@ -768,7 +703,7 @@
stasis_publish(topic, msg);
- dispatch_single_message(sub, topic, msg);
+ dispatch_message(sub, msg);
}
struct topic_pool_entry {
Modified: team/dlee/tp-local/main/stasis_cache.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/tp-local/main/stasis_cache.c?view=diff&rev=399780&r1=399779&r2=399780
==============================================================================
--- team/dlee/tp-local/main/stasis_cache.c (original)
+++ team/dlee/tp-local/main/stasis_cache.c Wed Sep 25 13:18:59 2013
@@ -354,7 +354,6 @@
RAII_VAR(struct stasis_cache_update *, update, NULL, ao2_cleanup);
RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
- ast_assert(topic != NULL);
ast_assert(old_snapshot != NULL || new_snapshot != NULL);
update = ao2_alloc_options(sizeof(*update), stasis_cache_update_dtor,
@@ -363,8 +362,6 @@
return NULL;
}
- ao2_ref(topic, +1);
- update->topic = topic;
if (old_snapshot) {
ao2_ref(old_snapshot, +1);
update->old_snapshot = old_snapshot;
More information about the asterisk-commits
mailing list