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

Jenkins2 asteriskteam at digium.com
Wed Jul 26 07:09:31 CDT 2017


Jenkins2 has submitted this change and it was merged. ( 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(-)

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



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: merged
Gerrit-Change-Id: I718b70d770a086e39b4ddba4f69a3c616d4476c4
Gerrit-Change-Number: 6083
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-code-review/attachments/20170726/71445957/attachment.html>


More information about the asterisk-code-review mailing list