Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 294820) +++ apps/app_voicemail.c (working copy) @@ -2623,6 +2623,7 @@ ast_log(LOG_WARNING, "The code expects the old messages to be checked first, fix the code.\n"); } if (vm_allocate_dh(vms, vmu, box == 0 ? vms->vmArrayIndex + vms->oldmessages : vms->lastmsg)) { + ast_mutex_unlock(&vms->lock); return -1; } @@ -7703,7 +7704,7 @@ if (vm_lock_path(vms->curdir)) { ast_log(AST_LOG_ERROR, "Could not open mailbox %s: mailbox is locked\n", vms->curdir); - return -1; + return ERROR_LOCK_PATH; } /* for local storage, checks directory for messages up to maxmsg limit */ @@ -9789,20 +9790,20 @@ /* Retrieve urgent, old and new message counts */ ast_debug(1, "Before open_mailbox\n"); res = open_mailbox(&vms, vmu, OLD_FOLDER); /* Count all messages, even Urgent */ - if (res < 0) + if (res == ERROR_LOCK_PATH) goto out; vms.oldmessages = vms.lastmsg + 1; ast_debug(1, "Number of old messages: %d\n", vms.oldmessages); /* check INBOX */ res = open_mailbox(&vms, vmu, NEW_FOLDER); - if (res < 0) + if (res < ERROR_LOCK_PATH) goto out; vms.newmessages = vms.lastmsg + 1; ast_debug(1, "Number of new messages: %d\n", vms.newmessages); /* Start in Urgent */ in_urgent = 1; res = open_mailbox(&vms, vmu, 11); /*11 is the Urgent folder */ - if (res < 0) + if (res < ERROR_LOCK_PATH) goto out; vms.urgentmessages = vms.lastmsg + 1; ast_debug(1, "Number of urgent messages: %d\n", vms.urgentmessages); @@ -9816,7 +9817,7 @@ in_urgent = 0; res = open_mailbox(&vms, vmu, play_folder); } - if (res < 0) + if (res == ERROR_LOCK_PATH) goto out; /* If there are no new messages, inform the user and hangup */ @@ -9832,13 +9833,13 @@ res = open_mailbox(&vms, vmu, OLD_FOLDER); /* Count all messages, even Urgent */ in_urgent = 0; play_folder = 1; - if (res < 0) + if (res == ERROR_LOCK_PATH) goto out; } else if (!vms.urgentmessages && vms.newmessages) { /* If we have new messages but none are urgent */ in_urgent = 0; res = open_mailbox(&vms, vmu, NEW_FOLDER); - if (res < 0) + if (res == ERROR_LOCK_PATH) goto out; } } @@ -9906,7 +9907,7 @@ /* If folder is not urgent, set in_urgent to zero! */ if (cmd != 11) in_urgent = 0; res = open_mailbox(&vms, vmu, cmd); - if (res < 0) + if (res == ERROR_LOCK_PATH) goto out; play_folder = cmd; cmd = 0; @@ -10037,7 +10038,7 @@ if (res == ERROR_LOCK_PATH) goto out; res = open_mailbox(&vms, vmu, 11); /* Open Urgent folder */ - if (res < 0) + if (res == ERROR_LOCK_PATH) goto out; ast_debug(1, "No more new messages, opened INBOX and got %d Urgent messages\n", vms.lastmsg + 1); vms.curmsg = vms.lastmsg; @@ -10066,7 +10067,7 @@ if (res == ERROR_LOCK_PATH) goto out; res = open_mailbox(&vms, vmu, NEW_FOLDER); - if (res < 0) + if (res == ERROR_LOCK_PATH) goto out; ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n", vms.lastmsg + 1); vms.curmsg = -1; @@ -10128,7 +10129,7 @@ if (res == ERROR_LOCK_PATH) goto out; res = open_mailbox(&vms, vmu, NEW_FOLDER); - if (res < 0) + if (res == ERROR_LOCK_PATH) goto out; ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n", vms.lastmsg + 1); vms.curmsg = -1; @@ -10165,7 +10166,7 @@ if (res == ERROR_LOCK_PATH) goto out; res = open_mailbox(&vms, vmu, NEW_FOLDER); - if (res < 0) + if (res == ERROR_LOCK_PATH) goto out; ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n", vms.lastmsg + 1); vms.curmsg = -1; @@ -10238,7 +10239,7 @@ if (res == ERROR_LOCK_PATH) goto out; res = open_mailbox(&vms, vmu, NEW_FOLDER); - if (res < 0) + if (res == ERROR_LOCK_PATH) goto out; ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n", vms.lastmsg + 1); vms.curmsg = -1;