<p>Joshua Colp would like Evgenios Muratidis to <strong>review</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15932">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">stasis: Fix "FRACK!, Failed assertion bad magic number" when unsubscribing<br><br>When unsubscribing from an endpoint technology a FRACK<br>would occur due to incorrect reference counting. This fixes<br>that issue, along with some other issues.<br><br>Fixed a typo in get_subscription when calling ao2_find as it<br>needed to pass the endpoint ID and not the entire object.<br><br>Fixed scenario where a subscription would get returned when<br>it shouldn't have been when searching based on endpoint<br>technology.<br><br>A doulbe unreference has also been resolved by only explicitly<br>releasing the reference held by tech_subscriptions.<br><br>ASTERISK-28237 #close<br>Reported by: Lucas Tardioli Silveira<br><br>Change-Id: Ia91b15f8e5ea68f850c66889a6325d9575901729<br>---<br>M res/stasis/messaging.c<br>1 file changed, 12 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/32/15932/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/stasis/messaging.c b/res/stasis/messaging.c</span><br><span>index 2caa8ed..e1d54c4 100644</span><br><span>--- a/res/stasis/messaging.c</span><br><span>+++ b/res/stasis/messaging.c</span><br><span>@@ -396,7 +396,7 @@</span><br><span> struct message_subscription *sub = NULL;</span><br><span> </span><br><span> if (endpoint && !ast_strlen_zero(ast_endpoint_get_resource(endpoint))) {</span><br><span style="color: hsl(0, 100%, 40%);">- sub = ao2_find(endpoint_subscriptions, endpoint, OBJ_SEARCH_KEY);</span><br><span style="color: hsl(120, 100%, 40%);">+ sub = ao2_find(endpoint_subscriptions, ast_endpoint_get_id(endpoint), OBJ_SEARCH_KEY);</span><br><span> } else {</span><br><span> int i;</span><br><span> </span><br><span>@@ -408,6 +408,11 @@</span><br><span> ao2_bump(sub);</span><br><span> break;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Need to reset the pointer at this line to prevent from using the wrong subscription due to</span><br><span style="color: hsl(120, 100%, 40%);">+ * the token check failing.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ sub = NULL;</span><br><span> }</span><br><span> ast_rwlock_unlock(&tech_subscriptions_lock);</span><br><span> }</span><br><span>@@ -441,10 +446,10 @@</span><br><span> AST_VECTOR_REMOVE_CMP_UNORDERED(&tech_subscriptions, endpoint ? ast_endpoint_get_id(endpoint) : TECH_WILDCARD,</span><br><span> messaging_subscription_cmp, AST_VECTOR_ELEM_CLEANUP_NOOP);</span><br><span> ast_rwlock_unlock(&tech_subscriptions_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(sub, -1); /* Release the reference held by tech_subscriptions */</span><br><span> }</span><br><span> }</span><br><span> ao2_unlock(sub);</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_ref(sub, -1);</span><br><span> </span><br><span> ast_debug(3, "App '%s' unsubscribed to messages from endpoint '%s'\n", app_name, endpoint ? ast_endpoint_get_id(endpoint) : "-- ALL --");</span><br><span> ast_test_suite_event_notify("StasisMessagingSubscription", "SubState: Unsubscribed\r\nAppName: %s\r\nToken: %s\r\n",</span><br><span>@@ -464,6 +469,11 @@</span><br><span> return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Either endpoint_subscriptions or tech_subscriptions will hold a reference to</span><br><span style="color: hsl(120, 100%, 40%);">+ * the subscription. This reference is released to allow the subscription to</span><br><span style="color: hsl(120, 100%, 40%);">+ * eventually destruct when there are no longer any applications receiving</span><br><span style="color: hsl(120, 100%, 40%);">+ * events from the subscription.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span> if (endpoint && !ast_strlen_zero(ast_endpoint_get_resource(endpoint))) {</span><br><span> ao2_link(endpoint_subscriptions, sub);</span><br><span> } else {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15932">change 15932</a>. To unsubscribe, or for help writing mail filters, 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/c/asterisk/+/15932"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ia91b15f8e5ea68f850c66889a6325d9575901729 </div>
<div style="display:none"> Gerrit-Change-Number: 15932 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Evgenios Muratidis <jone1984@hotmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>