aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-02-28 00:33:15 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-02-28 00:33:15 +0000
commit9593d31c2b7e2399318daa0c742930e2621ca02f (patch)
treed3633f15a37c2314cf849dd333a830e1602e7a97 /apps
parentd81d4a32b8f4c2c77c6eda65c369e4c0e8081558 (diff)
Don't write duration if file disappears (bug #1102 -- thanks hmodes)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2275 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rwxr-xr-xapps/app_voicemail.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index b83a20956..dd3e315fb 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1338,6 +1338,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
FILE *txt;
int res = 0;
int msgnum;
+ int fd;
char date[256];
char dir[256];
char fn[256];
@@ -1473,11 +1474,15 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
res = play_and_record(chan, NULL, fn, vmmaxmessage, fmt);
if (res > 0)
res = 0;
- txt = fopen(txtfile, "a");
- if (txt) {
- time(&end);
- fprintf(txt, "duration=%ld\n", (long)(end-start));
- fclose(txt);
+ fd = open(txtfile, O_APPEND | O_WRONLY);
+ if (fd > -1) {
+ txt = fdopen(fd, "a");
+ if (txt) {
+ time(&end);
+ fprintf(txt, "duration=%ld\n", (long)(end-start));
+ fclose(txt);
+ } else
+ close(fd);
}
stringp = fmt;
strsep(&stringp, "|");