[asterisk-commits] kmoore: branch kmoore/stasis-mwi r382506 - in /team/kmoore/stasis-mwi: includ...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 6 10:48:19 CST 2013
Author: kmoore
Date: Wed Mar 6 10:48:16 2013
New Revision: 382506
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382506
Log:
Cleanup and ensure that caching topics are unsubscribed properly
Modified:
team/kmoore/stasis-mwi/include/asterisk/stasis.h
team/kmoore/stasis-mwi/main/app.c
team/kmoore/stasis-mwi/main/stasis.c
team/kmoore/stasis-mwi/main/stasis_cache.c
Modified: team/kmoore/stasis-mwi/include/asterisk/stasis.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-mwi/include/asterisk/stasis.h?view=diff&rev=382506&r1=382505&r2=382506
==============================================================================
--- team/kmoore/stasis-mwi/include/asterisk/stasis.h (original)
+++ team/kmoore/stasis-mwi/include/asterisk/stasis.h Wed Mar 6 10:48:16 2013
@@ -460,7 +460,6 @@
*
* \param original_topic Topic publishing snapshot messages.
* \param id_fn Callback to extract the id from a snapshot message.
- * \param[out] Subscription produced by the caching backend held for the life of the cache concurrently with the returned stasis_caching_topic.
* \return New topic which changes snapshot messages to stasis_cache_update()
* messages, and forwards all other messages from the original topic.
* \since 12
Modified: team/kmoore/stasis-mwi/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-mwi/main/app.c?view=diff&rev=382506&r1=382505&r2=382506
==============================================================================
--- team/kmoore/stasis-mwi/main/app.c (original)
+++ team/kmoore/stasis-mwi/main/app.c Wed Mar 6 10:48:16 2013
@@ -2786,7 +2786,7 @@
{
ao2_cleanup(__mwi_topic_all);
__mwi_topic_all = NULL;
- ao2_cleanup(__mwi_topic_cached);
+ stasis_caching_unsubscribe(__mwi_topic_cached);
__mwi_topic_cached = NULL;
ao2_cleanup(__mwi_message_type);
__mwi_message_type = NULL;
@@ -2798,11 +2798,23 @@
int app_init(void)
{
+ ast_register_atexit(app_exit);
__mwi_topic_all = stasis_topic_create("stasis_mwi_topic");
+ if (!__mwi_topic_all) {
+ return -1;
+ }
__mwi_topic_cached = stasis_caching_topic_create(__mwi_topic_all, mwi_state_get_id);
+ if (!__mwi_topic_cached) {
+ return -1;
+ }
__mwi_message_type = stasis_message_type_create("stasis_mwi_state");
+ if (!__mwi_message_type) {
+ return -1;
+ }
__mwi_topics = ao2_container_alloc(MWI_TOPIC_BUCKETS, mwi_topic_hash, mwi_topic_cmp);
- ast_register_atexit(app_exit);
+ if (!__mwi_topics) {
+ return -1;
+ }
return 0;
}
Modified: team/kmoore/stasis-mwi/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-mwi/main/stasis.c?view=diff&rev=382506&r1=382505&r2=382506
==============================================================================
--- team/kmoore/stasis-mwi/main/stasis.c (original)
+++ team/kmoore/stasis-mwi/main/stasis.c Wed Mar 6 10:48:16 2013
@@ -339,8 +339,8 @@
struct stasis_subscription **subscribers = NULL;
size_t num_subscribers, i;
+ /* Copy the subscribers, so we don't have to hold the mutex for long */
{
- /* Copy the subscribers, so we don't have to hold the mutex for long */
SCOPED_AO2LOCK(lock, topic);
num_subscribers = topic->num_subscribers_current;
subscribers = ast_malloc(num_subscribers * sizeof(*subscribers));
Modified: team/kmoore/stasis-mwi/main/stasis_cache.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-mwi/main/stasis_cache.c?view=diff&rev=382506&r1=382505&r2=382506
==============================================================================
--- team/kmoore/stasis-mwi/main/stasis_cache.c (original)
+++ team/kmoore/stasis-mwi/main/stasis_cache.c Wed Mar 6 10:48:16 2013
@@ -410,8 +410,8 @@
struct stasis_caching_topic *stasis_caching_topic_create(struct stasis_topic *original_topic, snapshot_get_id id_fn)
{
RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
+ struct stasis_subscription *sub;
RAII_VAR(char *, new_name, NULL, free);
- struct stasis_subscription *sub;
int ret;
ret = asprintf(&new_name, "%s-cached", stasis_topic_name(original_topic));
More information about the asterisk-commits
mailing list