From: George Joseph Date: Tue, 18 Dec 2018 16:33:50 +0000 (-0700) Subject: app_voicemail: Don't delete mailbox state unless mailbox is deleted X-Git-Tag: 16.2.0-rc1~36^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aebb822d1f5604a376f78e1d8ae555580aad4d64;p=thirdparty%2Fasterisk.git app_voicemail: Don't delete mailbox state unless mailbox is deleted The free_user function was automatically deleting the stasis mailbox state but this only makes sense when the mailbox is actually deleted, not just the structure freed. This was causing issues where leave_voicemail would publish the mwi message to stasis and delete the state before the message could be processed by res_pjsip_mwi. * Removed the delete of state from free_user(). * Created a new free_user_final() function that both frees the data structure and deletes the state. This function is only called during module load/unload where it's appropriate to delete the state. ASTERISK-28215 Change-Id: I305e8b3c930e9ac41d901e5dc8a58fd7904d98dd --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 13dedd3d33..fb5ee88e56 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -2043,10 +2043,6 @@ static void free_user(struct ast_vm_user *vmu) return; } - if (!ast_strlen_zero(vmu->mailbox)) { - ast_delete_mwi_state_full(vmu->mailbox, vmu->context, NULL); - } - ast_free(vmu->email); vmu->email = NULL; ast_free(vmu->emailbody); @@ -2059,6 +2055,19 @@ static void free_user(struct ast_vm_user *vmu) } } +static void free_user_final(struct ast_vm_user *vmu) +{ + if (!vmu) { + return; + } + + if (!ast_strlen_zero(vmu->mailbox)) { + ast_delete_mwi_state_full(vmu->mailbox, vmu->context, NULL); + } + + free_user(vmu); +} + static int vm_allocate_dh(struct vm_state *vms, struct ast_vm_user *vmu, int count_msg) { int arraysize = (vmu->maxmsg > count_msg ? vmu->maxmsg : count_msg); @@ -13540,7 +13549,7 @@ static void free_vm_users(void) AST_LIST_LOCK(&users); while ((current = AST_LIST_REMOVE_HEAD(&users, list))) { ast_set_flag(current, VM_ALLOCED); - free_user(current); + free_user_final(current); } AST_LIST_UNLOCK(&users); }