Make stasis unsubscription functions return NULL
[asterisk/asterisk.git] / main / stasis.c
index f94736b..7f18bf5 100644 (file)
@@ -172,7 +172,7 @@ struct stasis_subscription *stasis_subscribe(struct stasis_topic *topic, stasis_
        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 @@ void stasis_unsubscribe(struct stasis_subscription *sub)
                                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)
@@ -337,6 +338,10 @@ void stasis_forward_message(struct stasis_topic *topic, struct stasis_topic *pub
        struct stasis_subscription **subscribers = NULL;
        size_t num_subscribers, i;
 
+       ast_assert(topic != NULL);
+       ast_assert(publisher_topic != NULL);
+       ast_assert(message != NULL);
+
        /* Copy the subscribers, so we don't have to hold the mutex for long */
        {
                SCOPED_AO2LOCK(lock, topic);