From 92ac547749ea6d1b298811737ecf4328e142174e Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 21 Jul 2006 22:12:38 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@554 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_http.c | 1 - varnish-cache/bin/varnishd/cache_vrt.c | 4 +++- varnish-cache/bin/varnishd/storage_file.c | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index 9315f73c..4850c441 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -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 ":"; diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index b42f4f14..2e46f843 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -115,7 +115,9 @@ VRT_l_obj_ttl(struct sess *sp, double a) 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); } diff --git a/varnish-cache/bin/varnishd/storage_file.c b/varnish-cache/bin/varnishd/storage_file.c index 2aedafd1..494d2351 100644 --- a/varnish-cache/bin/varnishd/storage_file.c +++ b/varnish-cache/bin/varnishd/storage_file.c @@ -70,7 +70,7 @@ smf_calcsize(struct smf_sc *sc, const char *size, int newfile) 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 @@ smf_calcsize(struct smf_sc *sc, const char *size, int newfile) 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 @@ smf_calcsize(struct smf_sc *sc, const char *size, int newfile) /* 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 @@ smf_open(struct stevedore *st) (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)); } -- 2.39.5