From: phk Date: Fri, 21 Jul 2006 21:28:51 +0000 (+0000) Subject: Implement TTL adjustment from VCL X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=973b86bb63ebf9e4be549b3c8a3c146be1f63c8d;p=varnish Implement TTL adjustment from VCL Log in shmem where the TTL came from (doc-candidate): 696613561 RFC 900 1153517009 1153517014 1153517914 900 0 | | | | | | | | | | | | | | | age | | | | | | max-age | | | | | Expires: header | | | | Date: header | | | "now" | | TTL relative to "now" | who set the TTL xid of object or 696613561 VCL 20 1153517009 | | | | | | | "now" | | TTL relative to "now" | who set the TTL xid of object git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@551 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 6ed7b92e..b42f4f14 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -113,7 +113,11 @@ VRT_l_obj_ttl(struct sess *sp, double a) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - (void)a; + 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 (sp->obj->heap_idx != 0) + EXP_TTLchange(sp->obj); } double diff --git a/varnish-cache/bin/varnishd/rfc2616.c b/varnish-cache/bin/varnishd/rfc2616.c index f20ca5ee..ee6e1631 100644 --- a/varnish-cache/bin/varnishd/rfc2616.c +++ b/varnish-cache/bin/varnishd/rfc2616.c @@ -71,7 +71,7 @@ #endif static time_t -RFC2616_Ttl(int fd, struct http *hp, time_t t_req, time_t t_resp, struct object *obj) +RFC2616_Ttl(struct sess *sp, struct http *hp, time_t t_req, time_t t_resp, struct object *obj) { int retirement_age; unsigned u1, u2; @@ -119,7 +119,7 @@ RFC2616_Ttl(int fd, struct http *hp, time_t t_req, time_t t_resp, struct object } /* calculated TTL, Our time, Date, Expires, max-age, age */ - VSL(SLT_TTL, fd, "%d %d %d %d %d %d", + VSL(SLT_TTL, sp->fd, "%u RFC %d %d %d %d %d %d", sp->xid, (int)(ttd - t_req), (int)t_req, (int)h_date, (int)h_expires, (int)u1, (int)u2); @@ -155,7 +155,7 @@ RFC2616_cache_policy(struct sess *sp, struct http *hp) break; } - sp->obj->ttl = RFC2616_Ttl(sp->fd, hp, sp->t_req, sp->t_resp, sp->obj); + sp->obj->ttl = RFC2616_Ttl(sp, hp, sp->t_req, sp->t_resp, sp->obj); sp->obj->entered = sp->t_req; if (sp->obj->ttl == 0) { sp->obj->cacheable = 0;