[master] 6633013 Make RFC2616_Ttl() take a busyobj

Poul-Henning Kamp phk at varnish-cache.org
Sun Feb 19 11:23:01 CET 2012


commit 66330133c7c9bf3f454e2bea5140d8fbf29c9baa
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Feb 19 10:21:44 2012 +0000

    Make RFC2616_Ttl() take a busyobj

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 9a560c3..a8cf350 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -997,7 +997,7 @@ char *WS_Alloc(struct ws *ws, unsigned bytes);
 char *WS_Snapshot(struct ws *ws);
 
 /* rfc2616.c */
-void RFC2616_Ttl(const struct sess *sp);
+void RFC2616_Ttl(struct busyobj *, unsigned xid);
 enum body_status RFC2616_Body(const struct sess *sp);
 unsigned RFC2616_Req_Gzip(const struct sess *sp);
 int RFC2616_Do_Cond(const struct sess *sp);
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index ad0817e..a58b834 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -606,7 +606,7 @@ cnt_fetch(struct sess *sp, struct worker *wrk, struct req *req)
 		 */
 		EXP_Clr(&wrk->busyobj->exp);
 		wrk->busyobj->exp.entered = W_TIM_real(wrk);
-		RFC2616_Ttl(sp);
+		RFC2616_Ttl(wrk->busyobj, sp->req->xid);
 
 		/* pass from vclrecv{} has negative TTL */
 		if (req->objcore == NULL)
diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c
index 2c3a368..2dafbd2 100644
--- a/bin/varnishd/cache/cache_rfc2616.c
+++ b/bin/varnishd/cache/cache_rfc2616.c
@@ -63,7 +63,7 @@
  */
 
 void
-RFC2616_Ttl(const struct sess *sp)
+RFC2616_Ttl(struct busyobj *bo, unsigned xid)
 {
 	unsigned max_age, age;
 	double h_date, h_expires;
@@ -71,9 +71,10 @@ RFC2616_Ttl(const struct sess *sp)
 	const struct http *hp;
 	struct exp *expp;
 
-	expp = &sp->wrk->busyobj->exp;
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	expp = &bo->exp;
 
-	hp = sp->wrk->busyobj->beresp;
+	hp = bo->beresp;
 
 	assert(expp->entered != 0.0 && !isnan(expp->entered));
 	/* If all else fails, cache using default ttl */
@@ -98,7 +99,7 @@ RFC2616_Ttl(const struct sess *sp)
 	if (http_GetHdr(hp, H_Date, &p))
 		h_date = VTIM_parse(p);
 
-	switch (sp->req->err_code) {
+	switch (http_GetStatus(hp)) {
 	default:
 		expp->ttl = -1.;
 		break;
@@ -167,9 +168,9 @@ RFC2616_Ttl(const struct sess *sp)
 	}
 
 	/* calculated TTL, Our time, Date, Expires, max-age, age */
-	VSLb(sp->req->vsl, SLT_TTL,	/* XXX Bo->vsl ? */
+	VSLb(bo->vsl, SLT_TTL,
 	    "%u RFC %.0f %.0f %.0f %.0f %.0f %.0f %.0f %u",
-	    sp->req->xid, expp->ttl, -1., -1., expp->entered,
+	    xid, expp->ttl, -1., -1., expp->entered,
 	    expp->age, h_date, h_expires, max_age);
 }
 



More information about the varnish-commit mailing list