[4.0] 43cc282 Give vrt_ctx a "double now" timestamp for use in VCL/VRT/VMODs

Lasse Karstensen lkarsten at varnish-software.com
Mon Sep 22 16:38:24 CEST 2014


commit 43cc2827c8f2be290fc95d18df2010060990fe0a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Aug 27 12:15:23 2014 +0000

    Give vrt_ctx a "double now" timestamp for use in VCL/VRT/VMODs
    
    Conflicts:
    	bin/varnishd/cache/cache_vcl.c
    	include/vrt.h

diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 63e8781..43c28c4 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -42,6 +42,7 @@
 #include "vrt.h"
 #include "vcli.h"
 #include "vcli_priv.h"
+#include "vtim.h"
 
 struct vcls {
 	unsigned		magic;
@@ -436,6 +437,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
 		ctx.req = req;
 		if (req->obj)
 			ctx.http_obj = req->obj->http;
+		ctx.now = req->t_prev;
 	}
 	if (bo != NULL) {
 		// AZ(req);
@@ -446,7 +448,10 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
 		ctx.http_bereq = bo->bereq;
 		ctx.http_beresp = bo->beresp;
 		ctx.bo = bo;
+		ctx.now = bo->t_prev;
 	}
+	if (ctx.now == 0)
+		ctx.now = VTIM_real();
 	ctx.ws = ws;
 	ctx.method = method;
 	ctx.handling = &wrk->handling;
diff --git a/include/vrt.h b/include/vrt.h
index ead55d3..e49926d 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -102,6 +102,7 @@ struct vrt_ctx {
 	struct http			*http_bereq;
 	struct http			*http_beresp;
 
+	double				now;
 };
 
 /***********************************************************************/



More information about the varnish-commit mailing list