[master] a982659 Give vrt_ctx a "double now" timestamp for use in VCL/VRT/VMODs

Poul-Henning Kamp phk at FreeBSD.org
Wed Aug 27 14:15:45 CEST 2014


commit a98265912a3b30f76726fa1b5a4ff0b5aabbdb4b
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

diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 345696e..521f291 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;
@@ -432,6 +433,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
 		ctx.http_req = req->http;
 		ctx.http_resp = req->resp;
 		ctx.req = req;
+		ctx.now = req->t_prev;
 	}
 	if (bo != NULL) {
 		CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
@@ -440,7 +442,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.vsl = vsl;
 	ctx.method = method;
diff --git a/include/vrt.h b/include/vrt.h
index cb47db9..90e85ea 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -41,7 +41,7 @@
 
 #define VRT_MAJOR_VERSION	2U
 
-#define VRT_MINOR_VERSION	0U
+#define VRT_MINOR_VERSION	1U
 
 
 /***********************************************************************/
@@ -101,6 +101,7 @@ struct vrt_ctx {
 	struct http			*http_bereq;
 	struct http			*http_beresp;
 
+	double				now;
 };
 
 /***********************************************************************/



More information about the varnish-commit mailing list