[asterisk-commits] kmoore: trunk r383168 - in /trunk: include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 15 07:58:27 CDT 2013


Author: kmoore
Date: Fri Mar 15 07:58:23 2013
New Revision: 383168

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383168
Log:
Make stasis unsubscription functions return NULL

Unsubscribing things in Asterisk seems to very commonly follow with
NULLing out the variable that was unsubscribed. This change makes that
a bit simpler.

Modified:
    trunk/include/asterisk/stasis.h
    trunk/main/stasis.c
    trunk/main/stasis_cache.c

Modified: trunk/include/asterisk/stasis.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/stasis.h?view=diff&rev=383168&r1=383167&r2=383168
==============================================================================
--- trunk/include/asterisk/stasis.h (original)
+++ trunk/include/asterisk/stasis.h Fri Mar 15 07:58:23 2013
@@ -306,9 +306,10 @@
  * delivery of the final message.
  *
  * \param subscription Subscription to cancel.
- * \since 12
- */
-void stasis_unsubscribe(struct stasis_subscription *subscription);
+ * \retval NULL for convenience
+ * \since 12
+ */
+struct stasis_subscription *stasis_unsubscribe(struct stasis_subscription *subscription);
 
 /*!
  * \brief Create a subscription which forwards all messages from one topic to
@@ -450,9 +451,10 @@
 /*!
  * Unsubscribes a caching topic from its upstream topic.
  * \param caching_topic Caching topic to unsubscribe
- * \since 12
- */
-void stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic);
+ * \retval NULL for convenience
+ * \since 12
+ */
+struct stasis_caching_topic *stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic);
 
 /*!
  * \brief Returns the topic of cached events from a caching topics.

Modified: trunk/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis.c?view=diff&rev=383168&r1=383167&r2=383168
==============================================================================
--- trunk/main/stasis.c (original)
+++ trunk/main/stasis.c Fri Mar 15 07:58:23 2013
@@ -172,7 +172,7 @@
 	return __stasis_subscribe(topic, callback, data, 1);
 }
 
-void stasis_unsubscribe(struct stasis_subscription *sub)
+struct stasis_subscription *stasis_unsubscribe(struct stasis_subscription *sub)
 {
 	if (sub) {
 		size_t i;
@@ -186,12 +186,13 @@
 				topic->subscribers[i] = topic->subscribers[--topic->num_subscribers_current];
 				/* Unsubscribing unrefs the subscription */
 				ao2_cleanup(sub);
-				return;
+				return NULL;
 			}
 		}
 
 		ast_log(LOG_ERROR, "Internal error: subscription has invalid topic\n");
 	}
+	return NULL;
 }
 
 int stasis_subscription_is_subscribed(const struct stasis_subscription *sub)

Modified: trunk/main/stasis_cache.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/stasis_cache.c?view=diff&rev=383168&r1=383167&r2=383168
==============================================================================
--- trunk/main/stasis_cache.c (original)
+++ trunk/main/stasis_cache.c Fri Mar 15 07:58:23 2013
@@ -65,7 +65,7 @@
 	return caching_topic->topic;
 }
 
-void stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic)
+struct stasis_caching_topic *stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic)
 {
 	if (caching_topic) {
 		if (stasis_subscription_is_subscribed(caching_topic->sub)) {
@@ -74,6 +74,7 @@
 			ast_log(LOG_ERROR, "stasis_caching_topic unsubscribed multiple times\n");
 		}
 	}
+	return NULL;
 }
 
 struct cache_entry {




More information about the asterisk-commits mailing list