aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-02-16 03:46:00 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-02-16 03:46:00 +0000
commitc5b4eda1c0e51bbb8d405aabe883d82baf0841e2 (patch)
treea3e40c0f2c04d7977e999b2020ca4bd19fa4ea68 /apps/app_voicemail.c
parent9f592c60af801a1baf7916858626b69d268b86b4 (diff)
Optimize vm storage (bug #3605)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5035 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_voicemail.c')
-rwxr-xr-xapps/app_voicemail.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index d39fbbd66..07099e1da 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -743,23 +743,15 @@ static int retrieve_file(char *dir, int msgnum)
goto yuck;
}
if (!strcmp(coltitle, "recording")) {
+ res = SQLGetData(stmt, x + 1, SQL_BINARY, NULL, 0, &colsize);
fdlen = colsize;
fd = open(full_fn, O_RDWR | O_TRUNC | O_CREAT, 0770);
if (fd > -1) {
- /* Ugh, gotta fill it so we can mmap */
- char tmp[1024]="";
- size_t left = 0, bytes = 0;
- left = fdlen;
- while(left) {
- bytes = left;
- if (bytes > sizeof(tmp))
- bytes = sizeof(tmp);
- if (write(fd, tmp, bytes) != bytes) {
- close(fd);
- fd = -1;
- break;
- }
- left -= bytes;
+ char tmp[1]="";
+ lseek(fd, fdlen - 1, SEEK_SET);
+ if (write(fd, tmp, 1) != 1) {
+ close(fd);
+ fd = -1;
}
if (fd > -1)
fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
@@ -772,8 +764,6 @@ static int retrieve_file(char *dir, int msgnum)
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
goto yuck;
}
- fdlen = colsize;
- ftruncate(fd, fdlen);
}
} else {
res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);