[Asterisk-code-review] res stasis device state: Unsubscribe should remove old subsc... (asterisk[13])

Sergej Kasumovic asteriskteam at digium.com
Tue Jul 25 07:57:23 CDT 2017


Sergej Kasumovic has uploaded this change for review. ( https://gerrit.asterisk.org/6083


Change subject: res_stasis_device_state: Unsubscribe should remove old subscriptions
......................................................................

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
---
M res/res_stasis_device_state.c
1 file changed, 3 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/83/6083/1

diff --git a/res/res_stasis_device_state.c b/res/res_stasis_device_state.c
index 29e7566..51101dd 100644
--- a/res/res_stasis_device_state.c
+++ b/res/res_stasis_device_state.c
@@ -108,7 +108,6 @@
 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);
 }
 
@@ -154,6 +153,9 @@
 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);
 }
 

-- 
To view, visit https://gerrit.asterisk.org/6083
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I718b70d770a086e39b4ddba4f69a3c616d4476c4
Gerrit-Change-Number: 6083
Gerrit-PatchSet: 1
Gerrit-Owner: Sergej Kasumovic <sergej at bicomsystems.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170725/64ef8e1e/attachment.html>


More information about the asterisk-code-review mailing list