aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2011-01-25 16:59:28 +0000
committerjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2011-01-25 16:59:28 +0000
commit75ca086244174231a7f3e80c0e04e7397005ab04 (patch)
tree4ab5c8ecddf265943e12433b785d04f07ed0cc65 /apps
parentdaec66ff61d1f37839f3533c2a9c0b05e603a4d8 (diff)
Merged revisions 303676 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r303676 | jpeeler | 2011-01-25 10:58:29 -0600 (Tue, 25 Jan 2011) | 20 lines Fix voicemail sequencing for file based storage. A previous change was made to account for when the number of voicemail messages exceeds the max limit to be handled properly, but it caused gaps in the messages to not be properly handled. This has now been resolved. In later non 1.4 branches, it appears that resequencing wasn't even occurring due from what appears and accidental code removal. (closes issue #18498) Reported by: JJCinAZ Patches: bug18498v2.patch uploaded by jpeeler (license 325) (closes issue #18486) Reported by: bluefox Patches: bug18486.patch uploaded by jpeeler (license 325) ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@303677 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_voicemail.c50
1 files changed, 46 insertions, 4 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 4ac2c5a49..0bcd8e82e 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -3762,6 +3762,8 @@ static int last_message_index(struct ast_vm_user *vmu, char *dir)
DIR *msgdir;
struct dirent *msgdirent;
int msgdirint;
+ char extension[3];
+ int stopcount = 0;
/* Reading the entire directory into a file map scales better than
* doing a stat repeatedly on a predicted sequence. I suspect this
@@ -3772,14 +3774,20 @@ static int last_message_index(struct ast_vm_user *vmu, char *dir)
}
while ((msgdirent = readdir(msgdir))) {
- if (sscanf(msgdirent->d_name, "msg%30d", &msgdirint) == 1 && msgdirint < MAXMSGLIMIT)
+ if (sscanf(msgdirent->d_name, "msg%30d.%3s", &msgdirint, extension) == 2 && msgdirint < MAXMSGLIMIT && !strcmp(extension, "txt")) {
map[msgdirint] = 1;
+ stopcount++;
+ ast_debug(4, "%s map[%d] = %d, count = %d\n", dir, msgdirint, map[msgdirint], stopcount);
+ }
}
closedir(msgdir);
for (x = 0; x < vmu->maxmsg; x++) {
- if (map[x] == 0)
+ if (map[x] == 1) {
+ stopcount--;
+ } else if (map[x] == 0 && !stopcount) {
break;
+ }
}
return x - 1;
@@ -5750,6 +5758,36 @@ leave_vm_out:
return res;
}
+#ifndef IMAP_STORAGE
+static int resequence_mailbox(struct ast_vm_user *vmu, char *dir, int stopcount)
+{
+ /* we know the actual number of messages, so stop process when number is hit */
+
+ int x, dest;
+ char sfn[PATH_MAX];
+ char dfn[PATH_MAX];
+
+ if (vm_lock_path(dir))
+ return ERROR_LOCK_PATH;
+
+ for (x = 0, dest = 0; dest != stopcount && x < vmu->maxmsg + 10; x++) {
+ make_file(sfn, sizeof(sfn), dir, x);
+ if (EXISTS(dir, x, sfn, NULL)) {
+
+ if (x != dest) {
+ make_file(dfn, sizeof(dfn), dir, dest);
+ RENAME(dir, x, vmu->mailbox, vmu->context, dir, dest, sfn, dfn);
+ }
+
+ dest++;
+ }
+ }
+ ast_unlock_path(dir);
+
+ return dest;
+}
+#endif
+
static int say_and_wait(struct ast_channel *chan, int num, const char *language)
{
int d;
@@ -7440,8 +7478,12 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, int box)
if (last_msg < -1) {
return last_msg;
- } else if (vms->lastmsg != last_msg) {
- ast_log(LOG_NOTICE, "Mailbox: %s, expected %d but found %d message(s) in box with max threshold of %d.\n", vms->curdir, last_msg + 1, vms->lastmsg + 1, vmu->maxmsg);
+ }
+#ifndef ODBC_STORAGE
+ else if (vms->lastmsg != last_msg) {
+ ast_log(LOG_NOTICE, "Resequencing mailbox: %s, expected %d but found %d message(s) in box with max threshold of %d.\n", vms->curdir, last_msg + 1, vms->lastmsg + 1, vmu->maxmsg);
+ resequence_mailbox(vmu, vms->curdir, count_msg);
+#endif
}
return 0;