summaryrefslogtreecommitdiff
path: root/res/res_stasis_device_state.c
diff options
context:
space:
mode:
authorSergej Kasumovic <sergej@bicomsystems.com>2017-07-20 15:08:05 +0200
committerSergej Kasumovic <sergej@bicomsystems.com>2017-07-25 07:58:21 -0500
commit4f4936fd72d92b394362f937c13c1cc1322d27ea (patch)
tree83af2f46f1846520db4a885ca8e1ceca73f09ac1 /res/res_stasis_device_state.c
parent63bcbb2a5698847d75e9106a8d0d04e6267781c7 (diff)
res_stasis_device_state: Unsubscribe should remove old subscriptions
Case scenario with Applications ARI: * Once you subscribe to deviceState with Applications REST API, it will be added into subscription pool. * When you unsubscribe it will remove from the device_state_subscription hash table but not from the subscription pool. * When you subscribe again, it will add it to pool again. * Now you will have two subscriptions and you will receive same event twice. This fix should now remove deviceState subscription from pool and it should fix unsubscribe on deviceState. ASTERISK-27130 #close Change-Id: I718b70d770a086e39b4ddba4f69a3c616d4476c4
Diffstat (limited to 'res/res_stasis_device_state.c')
-rw-r--r--res/res_stasis_device_state.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/res/res_stasis_device_state.c b/res/res_stasis_device_state.c
index 344cb40c9..276a98b93 100644
--- a/res/res_stasis_device_state.c
+++ b/res/res_stasis_device_state.c
@@ -106,7 +106,6 @@ static int device_state_subscriptions_cmp(void *obj, void *arg, int flags)
static void device_state_subscription_destroy(void *obj)
{
struct device_state_subscription *sub = obj;
- sub->sub = stasis_unsubscribe_and_join(sub->sub);
ast_string_field_free_memory(sub);
}
@@ -152,6 +151,9 @@ static struct device_state_subscription *find_device_state_subscription(
static void remove_device_state_subscription(
struct device_state_subscription *sub)
{
+ if (sub->sub) {
+ sub->sub = stasis_unsubscribe_and_join(sub->sub);
+ }
ao2_unlink_flags(device_state_subscriptions, sub, OBJ_NOLOCK);
}