[asterisk-commits] kmoore: branch kmoore/stasis-mwi r382470 - /team/kmoore/stasis-mwi/main/stasis.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 5 14:57:03 CST 2013


Author: kmoore
Date: Tue Mar  5 14:57:00 2013
New Revision: 382470

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382470
Log:
Fix a reference miss

Ensure stasis automatic forwards ref their to_topics properly so that
they survive the lifetime of the forwarding subscription.

Modified:
    team/kmoore/stasis-mwi/main/stasis.c

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=382470&r1=382469&r2=382470
==============================================================================
--- team/kmoore/stasis-mwi/main/stasis.c (original)
+++ team/kmoore/stasis-mwi/main/stasis.c Tue Mar  5 14:57:00 2013
@@ -385,15 +385,24 @@
 {
 	struct stasis_topic *to_topic = data;
 	stasis_forward_message(to_topic, topic, message);
+
+	if (stasis_subscription_final_message(sub, message)) {
+		ao2_cleanup(to_topic);
+	}
 }
 
 struct stasis_subscription *stasis_forward_all(struct stasis_topic *from_topic, struct stasis_topic *to_topic)
 {
+	struct stasis_subscription *sub;
 	if (!from_topic || !to_topic) {
 		return NULL;
 	}
 	/* Subscribe without a mailbox, since we're just forwarding messages */
-	return __stasis_subscribe(from_topic, stasis_forward_cb, to_topic, 0);
+	sub = __stasis_subscribe(from_topic, stasis_forward_cb, to_topic, 0);
+	if (sub) {
+		/* hold a ref to to_topic for this forwarding subscription */
+		ao2_ref(to_topic, +1);
+	}
 }
 
 static void subscription_change_dtor(void *obj)




More information about the asterisk-commits mailing list