aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-08 20:42:07 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-08 20:42:07 +0000
commit84b4fc21e7c1272cfa1d5b7de30669f14363fcdb (patch)
tree758e0716d34e5a7955ebf51a9d585b06bdae8ba9 /apps/app_voicemail.c
parent32be5ddcb013b94488569e3715f79a43af703f9f (diff)
Making some changes designed to not allow for a corrupted mailstream for a vm_state.
1. Add locking to the vm_state retrieval functions so that no linked list corruption occurs. 2. Make sure to always grab the persistent vm_state when mailstream access is necessary. 3. Correct an incorrect return value in the init_mailstream function. (closes issue #11304, reported by dwhite) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@97192 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 105b5e025..7b8b0dd23 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -2569,11 +2569,11 @@ static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int i
ast_log(LOG_WARNING, "Unable to copy mail, mailbox %s is full\n", recip->mailbox);
return -1;
}
- if (!(sendvms = get_vm_state_by_imapuser(vmu->imapuser, 2))) {
+ if (!(sendvms = get_vm_state_by_imapuser(vmu->imapuser, 0))) {
ast_log(LOG_ERROR, "Couldn't get vm_state for originator's mailbox!!\n");
return -1;
}
- if (!(destvms = get_vm_state_by_imapuser(recip->imapuser, 2))) {
+ if (!(destvms = get_vm_state_by_imapuser(recip->imapuser, 0))) {
ast_log(LOG_ERROR, "Couldn't get vm_state for destination mailbox!\n");
return -1;
}
@@ -4721,7 +4721,7 @@ static int init_mailstream(struct vm_state *vms, int box)
stream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
if (stream == NIL) {
ast_log (LOG_ERROR, "Can't connect to imap server %s\n", tmp);
- return NIL;
+ return -1;
}
get_mailbox_delimiter(stream);
/* update delimiter in imapfolder */
@@ -8805,6 +8805,7 @@ static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive)
{
struct vmstate *vlist = NULL;
+ ast_mutex_lock(&vmstate_lock);
vlist = vmstates;
while (vlist) {
if (vlist->vms) {
@@ -8826,6 +8827,7 @@ static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive)
}
vlist = vlist->next;
}
+ ast_mutex_unlock(&vmstate_lock);
if (option_debug > 2)
ast_log(LOG_DEBUG, "%s not found in vmstates\n",user);
return NULL;
@@ -8834,7 +8836,8 @@ 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)
{
struct vmstate *vlist = NULL;
-
+
+ ast_mutex_lock(&vmstate_lock);
vlist = vmstates;
if (option_debug > 2)
ast_log(LOG_DEBUG, "Mailbox set to %s\n",mailbox);
@@ -8858,6 +8861,7 @@ static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, int interac
}
vlist = vlist->next;
}
+ ast_mutex_unlock(&vmstate_lock);
if (option_debug > 2)
ast_log(LOG_DEBUG, "%s not found in vmstates\n",mailbox);
return NULL;