Index: apps/app_voicemail.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v retrieving revision 1.195 diff -u -r1.195 app_voicemail.c --- apps/app_voicemail.c 10 Jan 2005 05:29:46 -0000 1.195 +++ apps/app_voicemail.c 21 Jan 2005 13:59:21 -0000 @@ -280,6 +280,7 @@ static char *app4 = "VMAuthenticate"; AST_MUTEX_DEFINE_STATIC(vmlock); +AST_MUTEX_DEFINE_STATIC(filealloclock); struct ast_vm_user *users; struct ast_vm_user *usersl; struct vm_zone *zones = NULL; @@ -2132,6 +2133,7 @@ strncpy(fmt, vmfmts, sizeof(fmt) - 1); if (!ast_strlen_zero(fmt)) { msgnum = 0; + ast_mutex_lock(&filealloclock); do { make_file(fn, sizeof(fn), dir, msgnum); if (!EXISTS(dir,msgnum,fn,chan->language)) @@ -2177,6 +2179,7 @@ fclose(txt); } else ast_log(LOG_WARNING, "Error opening text file for output\n"); + ast_mutex_unlock(&filealloclock); res = play_record_review(chan, NULL, fn, vmmaxmessage, fmt, 1, vmu, &duration); if (res == '0') goto transfer; @@ -2220,6 +2223,7 @@ DISPOSE(dir, msgnum); } } else { + ast_mutex_unlock(&filealloclock); res = ast_streamfile(chan, "vm-mailboxfull", chan->language); if (!res) res = ast_waitstream(chan, ""); @@ -2247,7 +2251,7 @@ int x,dest; char sfn[256]; char dfn[256]; - + ast_mutex_lock(&filealloclock); for (x=0,dest=0;x= MAXMSG) - return -1; - if (strcmp(sfn, dfn)) { + res = -1; + if (res == 0 && strcmp(sfn, dfn)) { COPY(dir, msg, ddir, x, sfn, dfn); } - return 0; + ast_mutex_unlock(&filealloclock); + return res; } static int adsi_logo(unsigned char *buf) @@ -3401,6 +3409,7 @@ static void close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu) { int x; + ast_mutex_lock(&filealloclock); if (vms->lastmsg > -1) { /* Get the deleted messages fixed */ vms->curmsg = -1; @@ -3429,6 +3438,7 @@ } memset(vms->deleted, 0, sizeof(vms->deleted)); memset(vms->heard, 0, sizeof(vms->heard)); + ast_mutex_unlock(&filealloclock); } /* In Greek even though we CAN use a syntax like "friends messages"