<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/10819">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_voicemail:  Don't delete mailbox state unless mailbox is deleted<br><br>The free_user function was automatically deleting the stasis mailbox<br>state but this only makes sense when the mailbox is actually<br>deleted, not just the structure freed.  This was causing issues<br>where leave_voicemail would publish the mwi message to stasis and<br>delete the state before the message could be processed by<br>res_pjsip_mwi.<br><br>* Removed the delete of state from free_user().<br><br>* Created a new free_user_final() function that both frees the data<br>  structure and deletes the state.  This function is only called<br>  during module load/unload where it's appropriate to delete the<br>  state.<br><br>ASTERISK-28215<br><br>Change-Id: I305e8b3c930e9ac41d901e5dc8a58fd7904d98dd<br>---<br>M apps/app_voicemail.c<br>1 file changed, 14 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/19/10819/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c</span><br><span>index 85e1c38..1dd7aa0 100644</span><br><span>--- a/apps/app_voicemail.c</span><br><span>+++ b/apps/app_voicemail.c</span><br><span>@@ -2026,10 +2026,6 @@</span><br><span>               return;</span><br><span>      }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   if (!ast_strlen_zero(vmu->mailbox)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                ast_delete_mwi_state_full(vmu->mailbox, vmu->context, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-      }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>    ast_free(vmu->email);</span><br><span>     vmu->email = NULL;</span><br><span>        ast_free(vmu->emailbody);</span><br><span>@@ -2042,6 +2038,19 @@</span><br><span>        }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static void free_user_final(struct ast_vm_user *vmu)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!vmu) {</span><br><span style="color: hsl(120, 100%, 40%);">+           return;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (!ast_strlen_zero(vmu->mailbox)) {</span><br><span style="color: hsl(120, 100%, 40%);">+              ast_delete_mwi_state_full(vmu->mailbox, vmu->context, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   free_user(vmu);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static int vm_allocate_dh(struct vm_state *vms, struct ast_vm_user *vmu, int count_msg) {</span><br><span> </span><br><span>        int arraysize = (vmu->maxmsg > count_msg ? vmu->maxmsg : count_msg);</span><br><span>@@ -13491,7 +13500,7 @@</span><br><span>      AST_LIST_LOCK(&users);</span><br><span>   while ((current = AST_LIST_REMOVE_HEAD(&users, list))) {</span><br><span>                 ast_set_flag(current, VM_ALLOCED);</span><br><span style="color: hsl(0, 100%, 40%);">-              free_user(current);</span><br><span style="color: hsl(120, 100%, 40%);">+           free_user_final(current);</span><br><span>    }</span><br><span>    AST_LIST_UNLOCK(&users);</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10819">change 10819</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/10819"/><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: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I305e8b3c930e9ac41d901e5dc8a58fd7904d98dd </div>
<div style="display:none"> Gerrit-Change-Number: 10819 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>