Main fix: Fixing a bug which caused VoiceMailMain to always report that
you had 0 messages when using IMAP storage. Secondary fixes: adding locks to list access in several places Big thanks to Russell Bryant for helping out with this. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@70530 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
8ccfdf3c80
commit
3803718a8f
1 changed files with 34 additions and 15 deletions
|
@ -147,7 +147,7 @@ static void get_mailbox_delimiter(MAILSTREAM *stream);
|
||||||
static void mm_parsequota (MAILSTREAM *stream, unsigned char *msg, QUOTALIST *pquota);
|
static void mm_parsequota (MAILSTREAM *stream, unsigned char *msg, QUOTALIST *pquota);
|
||||||
static void imap_mailbox_name(char *spec, struct vm_state *vms, int box, int target);
|
static void imap_mailbox_name(char *spec, struct vm_state *vms, int box, int target);
|
||||||
static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms);
|
static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms);
|
||||||
|
static void update_messages_by_imapuser(const char *user, unsigned long number);
|
||||||
|
|
||||||
|
|
||||||
struct vmstate {
|
struct vmstate {
|
||||||
|
@ -8770,22 +8770,34 @@ static void write_file(char *filename, char *buffer, unsigned long len)
|
||||||
fclose (output);
|
fclose (output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void update_messages_by_imapuser(const char *user, unsigned long number)
|
||||||
|
{
|
||||||
|
struct vmstate *vlist = NULL;
|
||||||
|
|
||||||
|
AST_LIST_LOCK(&vmstates);
|
||||||
|
AST_LIST_TRAVERSE(&vmstates, vlist, list) {
|
||||||
|
if (!vlist->vms) {
|
||||||
|
ast_debug(3, "error: vms is NULL for %s\n", user);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!vlist->vms->imapuser) {
|
||||||
|
ast_debug(3, "error: imapuser is NULL for %s\n", user);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ast_debug(3, "saving mailbox message number %lu as message %d. Interactive set to %d\n", number, vlist->vms->vmArrayIndex, vlist->vms->interactive);
|
||||||
|
vlist->vms->msgArray[vlist->vms->vmArrayIndex++] = number;
|
||||||
|
}
|
||||||
|
AST_LIST_UNLOCK(&vmstates);
|
||||||
|
}
|
||||||
|
|
||||||
void mm_searched(MAILSTREAM *stream, unsigned long number)
|
void mm_searched(MAILSTREAM *stream, unsigned long number)
|
||||||
{
|
{
|
||||||
struct vm_state *vms;
|
|
||||||
char *mailbox = stream->mailbox, buf[1024] = "", *user;
|
char *mailbox = stream->mailbox, buf[1024] = "", *user;
|
||||||
|
|
||||||
if (!(user = get_user_by_mailbox(mailbox, buf, sizeof(buf))))
|
if (!(user = get_user_by_mailbox(mailbox, buf, sizeof(buf))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(vms = get_vm_state_by_imapuser(user, 2))) {
|
update_messages_by_imapuser(user, number);
|
||||||
ast_log(LOG_ERROR, "No state found.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ast_debug(3, "saving mailbox message number %lu as message %d. Interactive set to %d\n", number, vms->vmArrayIndex, vms->interactive);
|
|
||||||
|
|
||||||
vms->msgArray[vms->vmArrayIndex++] = number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9213,6 +9225,7 @@ static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive)
|
||||||
{
|
{
|
||||||
struct vmstate *vlist = NULL;
|
struct vmstate *vlist = NULL;
|
||||||
|
|
||||||
|
AST_LIST_LOCK(&vmstates);
|
||||||
AST_LIST_TRAVERSE(&vmstates, vlist, list) {
|
AST_LIST_TRAVERSE(&vmstates, vlist, list) {
|
||||||
if (!vlist->vms) {
|
if (!vlist->vms) {
|
||||||
ast_debug(3, "error: vms is NULL for %s\n", user);
|
ast_debug(3, "error: vms is NULL for %s\n", user);
|
||||||
|
@ -9223,11 +9236,12 @@ static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interactive == 2)
|
if (interactive == 2 || vlist->vms->interactive == interactive) {
|
||||||
return vlist->vms;
|
AST_LIST_UNLOCK(&vmstates);
|
||||||
else if (vlist->vms->interactive == interactive)
|
|
||||||
return vlist->vms;
|
return vlist->vms;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
AST_LIST_UNLOCK(&vmstates);
|
||||||
|
|
||||||
ast_debug(3, "%s not found in vmstates\n", user);
|
ast_debug(3, "%s not found in vmstates\n", user);
|
||||||
|
|
||||||
|
@ -9236,8 +9250,11 @@ static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive)
|
||||||
|
|
||||||
static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, int interactive)
|
static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, int interactive)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ast_debug (0, "I've been called with interactive = %d\n", interactive);
|
||||||
struct vmstate *vlist = NULL;
|
struct vmstate *vlist = NULL;
|
||||||
|
|
||||||
|
AST_LIST_LOCK(&vmstates);
|
||||||
AST_LIST_TRAVERSE(&vmstates, vlist, list) {
|
AST_LIST_TRAVERSE(&vmstates, vlist, list) {
|
||||||
if (!vlist->vms) {
|
if (!vlist->vms) {
|
||||||
ast_debug(3, "error: vms is NULL for %s\n", mailbox);
|
ast_debug(3, "error: vms is NULL for %s\n", mailbox);
|
||||||
|
@ -9252,9 +9269,11 @@ static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, int interac
|
||||||
|
|
||||||
if (!strcmp(vlist->vms->username,mailbox) && vlist->vms->interactive == interactive) {
|
if (!strcmp(vlist->vms->username,mailbox) && vlist->vms->interactive == interactive) {
|
||||||
ast_debug(3, "Found it!\n");
|
ast_debug(3, "Found it!\n");
|
||||||
|
AST_LIST_UNLOCK(&vmstates);
|
||||||
return vlist->vms;
|
return vlist->vms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AST_LIST_UNLOCK(&vmstates);
|
||||||
|
|
||||||
ast_debug(3, "%s not found in vmstates\n", mailbox);
|
ast_debug(3, "%s not found in vmstates\n", mailbox);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue