]> err.no Git - varnish/commitdiff
Unless the user specifies an explicit size, don't use more than 2GB
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 21 Jul 2006 22:12:38 +0000 (22:12 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 21 Jul 2006 22:12:38 +0000 (22:12 +0000)
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
varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/bin/varnishd/storage_file.c

index 9315f73cc9af86a0612d5b0690a9e0b2b1faaa39..4850c441c9cac54d1aa5c46057997925032ee467 100644 (file)
@@ -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 ":";
index b42f4f14694f10b87b0bd6882a94cf1c8d216810..2e46f8431e7ded6af524fa5d9c35c001785c072f 100644 (file)
@@ -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);
 }
index 2aedafd15f89a2e8e140598732a5833fbb4f7b74..494d2351663054a5200c890f71c2aef3c7cafe08 100644 (file)
@@ -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));
 }