<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 2:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 2:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 2:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 2:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 2:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 2:</p><p style="white-space: pre-wrap; word-wrap: break-word;">No, I'm not trying to make apps have subscription links too. They are not actually. It is only abstractly possible to assume that the application is referring to a subscription. In fact, the subscription object doesn't care who links to it. The only important thing is that if we want to subscribe several applications to one subscription, then we must increase the reference counter of the object of this subscription. Otherwise, there will be either a memory leak or an exception. Look at the example described above with three applications and one subscription again, please</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">With the current code yes, things are incorrect.</p><p style="white-space: pre-wrap; word-wrap: break-word;">I disagree however that we must increase the reference count. The unsubscribe code knows when no applications are present any longer as it does removal of itself at that point. Right now that reference counting for that situation is incorrect because of a double unref, my proposed change would rectify it. I've gone over my proposed change and don't see where the reference count would be incorrect.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I'm also working on testing to verify it.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Ok, try this example with asterisk built without my changes:<br>1. Subscribe with three different applications (app_1, app_2, app_3), for one technology subscription (SIP)</p><p style="white-space: pre-wrap; word-wrap: break-word;">2. Unsubscribe in turn those applications (app_1, app_2, app_3) from the subscription (SIP)</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">With no changes it causes errors, as I expected.<br>With moving the "ao2_ref(sub, -1);" no errors are encountered, the reference counting is correct, and the subscription is destroyed.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I also tested the endpoint specific subscription scenario with your ast_endpoint_get_id change and moving the "ao2_ref(sub, -1);" and it also works as expected - no errors, reference counting is correct, subscription is destroyed.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Could you show your changes, please, I don't understand, what you mean</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15762">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15762">change 15762</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/+/15762"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Ia91b15f8e5ea68f850c66889a6325d9575901729 </div>
<div style="display:none"> Gerrit-Change-Number: 15762 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Evgenios Muratidis <jone1984@hotmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Mon, 24 May 2021 14:02:42 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>