<p>Sergej Kasumovic has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6084">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_stasis_device_state: Unsubscribe should remove old subscriptions<br><br>Case scenario with Applications ARI:<br><br>* Once you subscribe to deviceState with Applications REST API, it will be<br>added into subscription pool.<br><br>* When you unsubscribe it will remove from the device_state_subscription<br>hash table but not from the subscription pool.<br><br>* When you subscribe again, it will add it to pool again.<br><br>* Now you will have two subscriptions and you will receive same event<br>twice.<br><br>This fix should now remove deviceState subscription from pool and it<br>should fix unsubscribe on deviceState.<br><br>ASTERISK-27130 #close<br><br>Change-Id: I718b70d770a086e39b4ddba4f69a3c616d4476c4<br>---<br>M res/res_stasis_device_state.c<br>1 file changed, 3 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/84/6084/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_stasis_device_state.c b/res/res_stasis_device_state.c<br>index 8356283..44cd03f 100644<br>--- a/res/res_stasis_device_state.c<br>+++ b/res/res_stasis_device_state.c<br>@@ -108,7 +108,6 @@<br> static void device_state_subscription_destroy(void *obj)<br> {<br> struct device_state_subscription *sub = obj;<br>- sub->sub = stasis_unsubscribe_and_join(sub->sub);<br> ast_string_field_free_memory(sub);<br> }<br> <br>@@ -154,6 +153,9 @@<br> static void remove_device_state_subscription(<br> struct device_state_subscription *sub)<br> {<br>+ if (sub->sub) {<br>+ sub->sub = stasis_unsubscribe_and_join(sub->sub);<br>+ }<br> ao2_unlink_flags(device_state_subscriptions, sub, OBJ_NOLOCK);<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6084">change 6084</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/6084"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 14 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I718b70d770a086e39b4ddba4f69a3c616d4476c4 </div>
<div style="display:none"> Gerrit-Change-Number: 6084 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sergej Kasumovic <sergej@bicomsystems.com> </div>