summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-05-17 21:10:32 +0000
committerDavid M. Lee <dlee@digium.com>2013-05-17 21:10:32 +0000
commitb97c71bb1190cb41eba9081d14724bcb39d422ba (patch)
tree2ae24b23411b0ab59b2239c4cefc5675c67de48e /channels
parent91bab7642281b593495284bd16744a6213cb6ea8 (diff)
Fix shutdown assertions in stasis-core
In r388005, macros were introduced to consistently define message types. This added an assert if a message type was used either before it was initialized or after it had been cleaned up. It turns out that this assertion fires during shutdown. This actually exposed a hidden shutdown ordering problem. Since unsubscribing is asynchronous, it's possible that the message types used by the subscription could be freed before the final message of the subscription was processed. This patch adds stasis_subscription_join(), which blocks until the last message has been processed by the subscription. Since joining was most commonly done right after an unsubscribe, a stasis_unsubscribe_and_join() convenience function was also added. Similar functions were also added to the stasis_caching_topic and stasis_message_router, since they wrap subscriptions and have similar problems. Other code in trunk was refactored to join() where appropriate, or at least verify that the subscription was complete before being destroyed. Review: https://reviewboard.asterisk.org/r/2540 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@389011 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c12
-rw-r--r--channels/chan_sip.c10
2 files changed, 6 insertions, 16 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index eeffb6696..112a99375 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1334,9 +1334,7 @@ static void network_change_stasis_subscribe(void)
static void network_change_stasis_unsubscribe(void)
{
- if (network_change_sub) {
- network_change_sub = stasis_unsubscribe(network_change_sub);
- }
+ network_change_sub = stasis_unsubscribe_and_join(network_change_sub);
}
static void acl_change_stasis_subscribe(void)
@@ -1349,9 +1347,7 @@ static void acl_change_stasis_subscribe(void)
static void acl_change_stasis_unsubscribe(void)
{
- if (acl_change_sub) {
- acl_change_sub = stasis_unsubscribe(acl_change_sub);
- }
+ acl_change_sub = stasis_unsubscribe_and_join(acl_change_sub);
}
static int network_change_sched_cb(const void *data)
@@ -12424,9 +12420,7 @@ static void peer_destructor(void *obj)
if (peer->dnsmgr)
ast_dnsmgr_release(peer->dnsmgr);
- if (peer->mwi_event_sub) {
- peer->mwi_event_sub = stasis_unsubscribe(peer->mwi_event_sub);
- }
+ peer->mwi_event_sub = stasis_unsubscribe(peer->mwi_event_sub);
ast_string_field_free_memory(peer);
}
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 937acb94e..88965fc73 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -16742,25 +16742,21 @@ static void network_change_stasis_subscribe(void)
static void network_change_stasis_unsubscribe(void)
{
- if (network_change_sub) {
- network_change_sub = stasis_unsubscribe(network_change_sub);
- }
+ network_change_sub = stasis_unsubscribe_and_join(network_change_sub);
}
static void acl_change_stasis_subscribe(void)
{
if (!acl_change_sub) {
acl_change_sub = stasis_subscribe(ast_security_topic(),
- acl_change_stasis_cb, NULL);
+ acl_change_stasis_cb, NULL);
}
}
static void acl_change_event_stasis_unsubscribe(void)
{
- if (acl_change_sub) {
- acl_change_sub = stasis_unsubscribe(acl_change_sub);
- }
+ acl_change_sub = stasis_unsubscribe_and_join(acl_change_sub);
}
static int network_change_sched_cb(const void *data)