[asterisk-commits] res stasis device state: Unsubscribe should remove old subsc... (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 26 08:27:32 CDT 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/6086 )

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(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  George Joseph: Looks good to me, approved



diff --git a/res/res_stasis_device_state.c b/res/res_stasis_device_state.c
index 344cb40..276a98b 100644
--- a/res/res_stasis_device_state.c
+++ b/res/res_stasis_device_state.c
@@ -106,7 +106,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);
 }
 
@@ -152,6 +151,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/6086
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I718b70d770a086e39b4ddba4f69a3c616d4476c4
Gerrit-Change-Number: 6086
Gerrit-PatchSet: 1
Gerrit-Owner: Sergej Kasumovic <sergej at bicomsystems.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170726/a5cbe1fa/attachment-0001.html>


More information about the asterisk-commits mailing list