<p>Alexei Gradinari <strong>posted comments</strong> on this change.</p><p><a href="https://gerrit.asterisk.org/5802">View Change</a></p><p>Patch set 1:</p><p>(3 comments)</p><ul style="list-style: none; padding-left: 20px;"><li><p><a href="https://gerrit.asterisk.org/#/c/5802/1/res/res_pjsip_mwi.c">File res/res_pjsip_mwi.c:</a></p><ul style="list-style: none; padding-left: 20px;"><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/5802/1/res/res_pjsip_mwi.c@1245">Patch Set #1, Line 1245:</a> <code style="font-family:monospace,monospace">  endpoint = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "endpoint", contact->endpoint_name);</code></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">Shouldn't contact->endpoint already be a pointer to the endpoint object?</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">I checked it, on delete the pointer is null.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/5802/1/res/res_pjsip_mwi.c@1251">Patch Set #1, Line 1251:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> ao2_lock(unsolicited_mwi);<br>    mwi_subs = ao2_find(unsolicited_mwi, contact->endpoint_name,<br>               OBJ_SEARCH_KEY | OBJ_MULTIPLE | OBJ_NOLOCK | OBJ_UNLINK);<br>     if (mwi_subs) {<br>               for (; (mwi_sub = ao2_iterator_next(mwi_subs)); ao2_cleanup(mwi_sub)) {<br>                       unsubscribe(mwi_sub, NULL, 0);<br>                }<br>             ao2_iterator_destroy(mwi_subs);<br>       }<br>     ao2_unlock(unsolicited_mwi);<br></pre></blockquote></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">The same logic is in mwi_contact_added.  Can you re-use it?</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">It's not simple reusable because in mwi_contact_added the lock contains both unsubscribe and subscribe. </p><p style="white-space: pre-wrap; word-wrap: break-word;">I do not fully understand why removing the old subscriptions first and then applying the new subscriptions in mwi_contact_added.</p><p style="white-space: pre-wrap; word-wrap: break-word;">I think the mwi_contact_deleted can be simplified if it's not necessary to remove/add subscription, i.e.<br>if deleted the last contact then remove all subscription<br>if exists the contact then do nothing with subscription.</p></li><li><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/5802/1/res/res_pjsip_mwi.c@1267">Patch Set #1, Line 1267:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">     ao2_lock(unsolicited_mwi);<br>    create_mwi_subscriptions_for_endpoint(endpoint, NULL, 0);<br>     ao2_unlock(unsolicited_mwi);<br>}<br></pre></blockquote></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">I don't understand why you are re-creating the subscriptions again.</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Because if there is another contact we should have the subscription again</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/5802">change 5802</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/5802"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: I33e174e0b9dba0998927d16d6d100fda5c7254e0 </div>
<div style="display:none"> Gerrit-Change-Number: 5802 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Comment-Date: Tue, 13 Jun 2017 14:30:51 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>