mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-07 02:18:15 +00:00
Merged revisions 111067 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r111067 | mmichelson | 2008-03-26 14:26:23 -0500 (Wed, 26 Mar 2008) | 17 lines Merged revisions 111049 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r111049 | mmichelson | 2008-03-26 14:22:16 -0500 (Wed, 26 Mar 2008) | 9 lines Add a lock to the vm_state structure and use the lock around mail_open calls to prevent concurrent access of the same mailstream. This, along with trunk's ability to configure TCP timeouts for IMAP storage will help to prevent crashes and hangs when using voicemail with IMAP storage. (closes issue #10487) Reported by: ewilhelmsen ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@111072 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -416,6 +416,7 @@ struct vm_state {
|
|||||||
int starting;
|
int starting;
|
||||||
int repeats;
|
int repeats;
|
||||||
#ifdef IMAP_STORAGE
|
#ifdef IMAP_STORAGE
|
||||||
|
ast_mutex_t lock;
|
||||||
int updated; /*!< decremented on each mail check until 1 -allows delay */
|
int updated; /*!< decremented on each mail check until 1 -allows delay */
|
||||||
long msgArray[256];
|
long msgArray[256];
|
||||||
MAILSTREAM *mailstream;
|
MAILSTREAM *mailstream;
|
||||||
@@ -5042,7 +5043,9 @@ static int init_mailstream(struct vm_state *vms, int box)
|
|||||||
#endif
|
#endif
|
||||||
/* Connect to mailbox to get mailstream so we can get delimiter */
|
/* Connect to mailbox to get mailstream so we can get delimiter */
|
||||||
imap_mailbox_name(tmp, sizeof(tmp), vms, 0, 1);
|
imap_mailbox_name(tmp, sizeof(tmp), vms, 0, 1);
|
||||||
|
ast_mutex_lock(&vms->lock);
|
||||||
stream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
|
stream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
|
||||||
|
ast_mutex_unlock(&vms->lock);
|
||||||
if (stream == NIL) {
|
if (stream == NIL) {
|
||||||
ast_log(LOG_ERROR, "Can't connect to imap server %s\n", tmp);
|
ast_log(LOG_ERROR, "Can't connect to imap server %s\n", tmp);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -5057,7 +5060,9 @@ static int init_mailstream(struct vm_state *vms, int box)
|
|||||||
/* Now connect to the target folder */
|
/* Now connect to the target folder */
|
||||||
imap_mailbox_name(tmp, sizeof(tmp), vms, box, 1);
|
imap_mailbox_name(tmp, sizeof(tmp), vms, box, 1);
|
||||||
ast_debug(3, "Before mail_open, server: %s, box:%d\n", tmp, box);
|
ast_debug(3, "Before mail_open, server: %s, box:%d\n", tmp, box);
|
||||||
vms->mailstream = mail_open(stream, tmp, debug ? OP_DEBUG : NIL);
|
ast_mutex_lock(&vms->lock);
|
||||||
|
vms->mailstream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
|
||||||
|
ast_mutex_unlock(&vms->lock);
|
||||||
if (vms->mailstream == NIL) {
|
if (vms->mailstream == NIL) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
@@ -9779,8 +9784,10 @@ static void vmstate_delete(struct vm_state *vms)
|
|||||||
AST_LIST_TRAVERSE_SAFE_END
|
AST_LIST_TRAVERSE_SAFE_END
|
||||||
AST_LIST_UNLOCK(&vmstates);
|
AST_LIST_UNLOCK(&vmstates);
|
||||||
|
|
||||||
if (vc)
|
if (vc) {
|
||||||
|
ast_mutex_destroy(&vms->lock);
|
||||||
ast_free(vc);
|
ast_free(vc);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ast_log(LOG_ERROR, "No vmstate found for user:%s, mailbox %s\n", vms->imapuser, vms->username);
|
ast_log(LOG_ERROR, "No vmstate found for user:%s, mailbox %s\n", vms->imapuser, vms->username);
|
||||||
}
|
}
|
||||||
@@ -9809,6 +9816,7 @@ static void init_vm_state(struct vm_state *vms)
|
|||||||
for (x = 0; x < 256; x++) {
|
for (x = 0; x < 256; x++) {
|
||||||
vms->msgArray[x] = 0;
|
vms->msgArray[x] = 0;
|
||||||
}
|
}
|
||||||
|
ast_mutex_init(&vms->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_msgArray(struct vm_state *vms)
|
static void check_msgArray(struct vm_state *vms)
|
||||||
|
|||||||
Reference in New Issue
Block a user