mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 03:08:45 +00:00
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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383168 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -306,9 +306,10 @@ struct stasis_subscription *stasis_subscribe(struct stasis_topic *topic,
|
|||||||
* delivery of the final message.
|
* delivery of the final message.
|
||||||
*
|
*
|
||||||
* \param subscription Subscription to cancel.
|
* \param subscription Subscription to cancel.
|
||||||
|
* \retval NULL for convenience
|
||||||
* \since 12
|
* \since 12
|
||||||
*/
|
*/
|
||||||
void stasis_unsubscribe(struct stasis_subscription *subscription);
|
struct stasis_subscription *stasis_unsubscribe(struct stasis_subscription *subscription);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Create a subscription which forwards all messages from one topic to
|
* \brief Create a subscription which forwards all messages from one topic to
|
||||||
@@ -450,9 +451,10 @@ struct stasis_caching_topic *stasis_caching_topic_create(struct stasis_topic *or
|
|||||||
/*!
|
/*!
|
||||||
* Unsubscribes a caching topic from its upstream topic.
|
* Unsubscribes a caching topic from its upstream topic.
|
||||||
* \param caching_topic Caching topic to unsubscribe
|
* \param caching_topic Caching topic to unsubscribe
|
||||||
|
* \retval NULL for convenience
|
||||||
* \since 12
|
* \since 12
|
||||||
*/
|
*/
|
||||||
void stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic);
|
struct stasis_caching_topic *stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Returns the topic of cached events from a caching topics.
|
* \brief Returns the topic of cached events from a caching topics.
|
||||||
|
@@ -172,7 +172,7 @@ struct stasis_subscription *stasis_subscribe(struct stasis_topic *topic, stasis_
|
|||||||
return __stasis_subscribe(topic, callback, data, 1);
|
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) {
|
if (sub) {
|
||||||
size_t i;
|
size_t i;
|
||||||
@@ -186,12 +186,13 @@ void stasis_unsubscribe(struct stasis_subscription *sub)
|
|||||||
topic->subscribers[i] = topic->subscribers[--topic->num_subscribers_current];
|
topic->subscribers[i] = topic->subscribers[--topic->num_subscribers_current];
|
||||||
/* Unsubscribing unrefs the subscription */
|
/* Unsubscribing unrefs the subscription */
|
||||||
ao2_cleanup(sub);
|
ao2_cleanup(sub);
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_log(LOG_ERROR, "Internal error: subscription has invalid topic\n");
|
ast_log(LOG_ERROR, "Internal error: subscription has invalid topic\n");
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int stasis_subscription_is_subscribed(const struct stasis_subscription *sub)
|
int stasis_subscription_is_subscribed(const struct stasis_subscription *sub)
|
||||||
|
@@ -65,7 +65,7 @@ struct stasis_topic *stasis_caching_get_topic(struct stasis_caching_topic *cachi
|
|||||||
return caching_topic->topic;
|
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 (caching_topic) {
|
||||||
if (stasis_subscription_is_subscribed(caching_topic->sub)) {
|
if (stasis_subscription_is_subscribed(caching_topic->sub)) {
|
||||||
@@ -74,6 +74,7 @@ void stasis_caching_unsubscribe(struct stasis_caching_topic *caching_topic)
|
|||||||
ast_log(LOG_ERROR, "stasis_caching_topic unsubscribed multiple times\n");
|
ast_log(LOG_ERROR, "stasis_caching_topic unsubscribed multiple times\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cache_entry {
|
struct cache_entry {
|
||||||
|
Reference in New Issue
Block a user