cvs: /php4/ext/standard file.c

From: Date: Sat, 11 Sep 1999 18:38:34 +0000
Subject: cvs: /php4/ext/standard file.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-4330@lists.php.net to get a copy of this message
sas Sat Sep 11 14:38:34 1999 EDT Modified files: /php4/ext/standard file.c Log: avoid mmap overhead for small files Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.27 php4/ext/standard/file.c:1.28 --- php4/ext/standard/file.c:1.27 Sat Sep 11 14:15:39 1999 +++ php4/ext/standard/file.c Sat Sep 11 14:38:34 1999 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.27 1999/09/11 18:15:39 sas Exp $ */ +/* $Id: file.c,v 1.28 1999/09/11 18:38:34 sas Exp $ */ /* Synced with php3 revision 1.218 1999-06-16 [ssb] */ @@ -1220,6 +1220,7 @@ { size_t bcount = 0; int ready = 0; + char buf[8192]; #ifdef HAVE_MMAP if(!issock) { @@ -1230,23 +1231,23 @@ size_t len; fd = fileno(fp); - off = ftell(fp); fstat(fd, &sbuf); - len = sbuf.st_size - off; - - p = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, off); - if(p!=MAP_FAILED) { - PHPWRITE(p, len); - munmap(p, len); - bcount += len; - ready = 1; + if(sbuf.st_size > sizeof(buf)) { + off = ftell(fp); + len = sbuf.st_size - off; + p = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, off); + if(p!=MAP_FAILED) { + PHPWRITE(p, len); + munmap(p, len); + bcount += len; + ready = 1; + } } } #endif if(!ready) { - char buf[8192]; int b; while ((b = FP_FREAD(buf, sizeof(buf), socketd, fp, issock)) > 0) {

« previous php.version4 (#4330) next »