<p><a href="https://gerrit.asterisk.org/10701">View Change</a></p><p>2 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.asterisk.org/#/c/10701/2/main/pbx.c">File main/pbx.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/10701/2/main/pbx.c@3316">Patch Set #2, Line 3316:</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;">          /* The extension has already been destroyed,<br>           * notify extension deactivation<br>               */<br></pre></blockquote></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">Is it now possible at all for this to be invoked multiple times?</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Nice shot! </p><p style="white-space: pre-wrap; word-wrap: break-word;">AFAICT it may happen since the device_state_notify_callbacks function is called from both handle_hint_change_message_type() (via stasis) and device_state_cb().</p><p style="white-space: pre-wrap; word-wrap: break-word;">We may add a check for hint->laststate value and return if it is equal to AST_EXTENSION_DEACTIVATED. This guarantees it's executed once because hint is locked and hint->laststate is changed few lines below</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/10701/2/main/pbx.c@3989">Patch Set #2, Line 3989:</a> <code style="font-family:monospace,monospace">       if (!(message = stasis_message_create(hint_change_message_type(), hint))) {</code></p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;">Why the removal of the second reference and comment? Was there a leak previously?</blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Yes, there was a leak.</p><p style="white-space: pre-wrap; word-wrap: break-word;">The stasis_message_create function calls stasis_message_create_full() that bumps hint ref once.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Then the new message is passed to statis_publish function that bumps message ref (within dispatch_message()), so bumping hint ref two times because of message being published to two topics is wrong and it causes mem leak.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/10701">change 10701</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/10701"/><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: I5b03c3455b3b12b6f83cea4cc34f4b4b20444f7e </div>
<div style="display:none"> Gerrit-Change-Number: 10701 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Giuseppe Sucameli <sucameli@netresults.it> </div>
<div style="display:none"> Gerrit-Reviewer: Giuseppe Sucameli <sucameli@netresults.it> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Wed, 28 Nov 2018 08:25:02 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: No </div>