[Asterisk-cvs] asterisk/apps app_voicemail.c,1.198,1.199

markster at lists.digium.com markster at lists.digium.com
Tue Feb 15 21:46:38 CST 2005


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv16038/apps

Modified Files:
	app_voicemail.c 
Log Message:
Optimize vm storage (bug #3605)


Index: app_voicemail.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_voicemail.c,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -d -r1.198 -r1.199
--- app_voicemail.c	25 Jan 2005 06:10:19 -0000	1.198
+++ app_voicemail.c	16 Feb 2005 03:46:00 -0000	1.199
@@ -743,23 +743,15 @@
 					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 @@
 							SQLFreeHandle (SQL_HANDLE_STMT, stmt);
 							goto yuck;
 						}
-						fdlen = colsize;
-						ftruncate(fd, fdlen);
 					}
 				} else {
 					res = SQLGetData(stmt, x + 1, SQL_CHAR, rowdata, sizeof(rowdata), NULL);




More information about the svn-commits mailing list