INN commit: branches/2.4/lib (dbz.c)

INN Commit Russ_Allbery at isc.org
Sat Feb 10 22:35:17 UTC 2007


    Date: Saturday, February 10, 2007 @ 14:35:16
  Author: eagle
Revision: 7605

Don't use ints; we lose with large files on many systems.  Use xpwrite
instead of pwrite to get complete writes.  Based on a patch by Chris
Caputo.

Modified:
  branches/2.4/lib/dbz.c

-------+
 dbz.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Modified: dbz.c
===================================================================
--- dbz.c	2007-02-10 22:32:15 UTC (rev 7604)
+++ dbz.c	2007-02-10 22:35:16 UTC (rev 7605)
@@ -701,7 +701,7 @@
 	free(tab->core);
     if (tab->incore == INCORE_MMAP) {
 #if defined(HAVE_MMAP)
-	if (munmap(tab->core, (int)conf.tsize * tab->reclen) == -1) {
+	if (munmap(tab->core, conf.tsize * tab->reclen) == -1) {
 	    syswarn("closehashtable: munmap failed");
 	}
 #else
@@ -1246,8 +1246,8 @@
 getcore(hash_table *tab)
 {
     char *it;
-    int nread;
-    int i;
+    ssize_t nread;
+    size_t i;
     struct stat st;
     size_t length = conf.tsize * tab->reclen;
 
@@ -1303,14 +1303,16 @@
 static bool
 putcore(hash_table *tab)
 {
-    int size;
+    size_t size;
+    ssize_t result;
     
     if (tab->incore == INCORE_MEM) {
 	if(options.writethrough)
 	    return true;
 	nonblocking(tab->fd, false);
 	size = tab->reclen * conf.tsize;
-	if (pwrite(tab->fd, tab->core, size, 0) != size) {
+	result = xpwrite(tab->fd, tab->core, size, 0);
+	if (result < 0 || (size_t) result != size) {
 	    nonblocking(tab->fd, options.nonblock);
 	    return false;
 	}
@@ -1318,7 +1320,7 @@
     }
 #ifdef HAVE_MMAP
     if(tab->incore == INCORE_MMAP) {
-	msync(tab->core, (int)conf.tsize * tab->reclen, MS_ASYNC);
+	msync(tab->core, conf.tsize * tab->reclen, MS_ASYNC);
     }
 #endif
     return true;



More information about the inn-committers mailing list