Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 294347) +++ apps/app_voicemail.c (working copy) @@ -2463,6 +2463,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; } @@ -7408,7 +7409,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 */ @@ -9397,20 +9398,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); @@ -9424,7 +9425,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 */ @@ -9440,13 +9441,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; } } @@ -9514,7 +9515,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; @@ -9645,7 +9646,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; @@ -9674,7 +9675,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; @@ -9736,7 +9737,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; @@ -9773,7 +9774,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; @@ -9846,7 +9847,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;