r554 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Sat Jul 22 00:12:38 CEST 2006


Author: phk
Date: 2006-07-22 00:12:38 +0200 (Sat, 22 Jul 2006)
New Revision: 554

Modified:
   trunk/varnish-cache/bin/varnishd/cache_http.c
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
   trunk/varnish-cache/bin/varnishd/storage_file.c
Log:
Unless the user specifies an explicit size, don't use more than 2GB
on 32 bit architectures to avoid running out of address room

Make FlexeLint happy.


Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2006-07-21 21:57:43 UTC (rev 553)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2006-07-21 22:12:38 UTC (rev 554)
@@ -13,7 +13,6 @@
 
 #include "libvarnish.h"
 #include "shmlog.h"
-#include "heritage.h"
 #include "cache.h"
 
 #define HTTPH(a, b, c, d, e, f, g) char b[] = "*" a ":";

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2006-07-21 21:57:43 UTC (rev 553)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2006-07-21 22:12:38 UTC (rev 554)
@@ -115,7 +115,9 @@
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);	/* XXX */
 	VSL(SLT_TTL, sp->fd, "%u VCL %.0f %u", sp->obj->xid, a, sp->t_req);
-	sp->obj->ttl = sp->t_req + a;
+	if (a < 0)
+		a = 0;
+	sp->obj->ttl = sp->t_req + (int)a;
 	if (sp->obj->heap_idx != 0)
 		EXP_TTLchange(sp->obj);
 }

Modified: trunk/varnish-cache/bin/varnishd/storage_file.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_file.c	2006-07-21 21:57:43 UTC (rev 553)
+++ trunk/varnish-cache/bin/varnishd/storage_file.c	2006-07-21 22:12:38 UTC (rev 554)
@@ -70,7 +70,7 @@
 	uintmax_t l;
 	unsigned bs;
 	char suff[2];
-	int i;
+	int i, expl;
 	off_t o;
 	struct statfs fsst;
 	struct stat st;
@@ -87,6 +87,7 @@
 
 	i = sscanf(size, "%ju%1s", &l, suff); /* can return -1, 0, 1 or 2 */
 
+	expl = i;
 	if (i == 0) {
 		fprintf(stderr,
 		    "Error: (-sfile) size \"%s\" not understood\n", size);
@@ -151,13 +152,22 @@
 	/* round down to of filesystem blocksize or pagesize */
 	l -= (l % bs);
 
-	if (l < MINPAGES * sc->pagesize) {
+	if (l < MINPAGES * (uintmax_t)sc->pagesize) {
 		fprintf(stderr,
 		    "Error: size too small, at least %ju needed\n",
 		    (uintmax_t)MINPAGES * sc->pagesize);
 		exit (2);
 	}
 
+	if (expl < 0 && sizeof(void *) == 4 && l > (1ULL << 31)) {
+		fprintf(stderr,
+		    "NB: Limiting size to 2GB on 32 bit architecture to"
+		    " prevent running out of\naddress space."
+		    "  Specifiy explicit size to override.\n"
+		);
+		l = 1ULL << 31;
+	}
+
 	printf("file %s size %ju bytes (%ju fs-blocks, %ju pages)\n",
 	    sc->filename, l, l / fsst.f_bsize, l / sc->pagesize);
 
@@ -471,7 +481,7 @@
 	    (uintmax_t)sum, sc->filesize);
 
 	/* XXX */
-	if (sum < MINPAGES * getpagesize())
+	if (sum < MINPAGES * (uintmax_t)getpagesize())
 		exit (2);
 	AZ(pthread_mutex_init(&sc->mtx, NULL));
 }




More information about the varnish-commit mailing list