[master] a5e7017 Move cur_method from req to wrk

Poul-Henning Kamp phk at varnish-cache.org
Mon Apr 22 09:52:38 CEST 2013


commit a5e701721035f00d7e791fcac27f765c519f0807
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Apr 22 07:52:23 2013 +0000

    Move cur_method from req to wrk

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 1b67d88..a7aad66 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -349,6 +349,7 @@ struct worker {
 
 	struct vxid_pool	vxid_pool;
 
+	unsigned		cur_method;
 	unsigned		handling;
 };
 
@@ -613,7 +614,6 @@ struct req {
 
 	enum sess_close		doclose;
 	struct exp		exp;
-	unsigned		cur_method;
 
 	unsigned char		wantbody;
 	enum req_body_state_e	req_body_status;
@@ -1014,7 +1014,8 @@ void VCL_Init(void);
 void VCL_Refresh(struct VCL_conf **vcc);
 void VCL_Rel(struct VCL_conf **vcc);
 void VCL_Poll(void);
-const char *VCL_Return_Name(unsigned method);
+const char *VCL_Return_Name(unsigned);
+const char *VCL_Method_Name(unsigned);
 
 #define VCL_MET_MAC(l,u,b) \
     void VCL_##l##_method(struct worker *, struct req *, struct ws *);
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index bc3accf..14c14b3 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -229,11 +229,17 @@ pan_wrk(const struct worker *wrk)
 
 	VSB_printf(pan_vsp, "  worker = %p {\n", wrk);
 	pan_ws(wrk->aws, 4);
+
+	hand = VCL_Method_Name(wrk->cur_method);
+	if (hand != NULL)
+		VSB_printf(pan_vsp, "  VCL::method = %s,\n", hand);
+	else
+		VSB_printf(pan_vsp, "  VCL::method = 0x%x,\n", wrk->cur_method);
 	hand = VCL_Return_Name(wrk->handling);
 	if (hand != NULL)
-		VSB_printf(pan_vsp, "  handling = %s,\n", hand);
+		VSB_printf(pan_vsp, "  VCL::return = %s,\n", hand);
 	else
-		VSB_printf(pan_vsp, "  handling = 0x%x,\n", wrk->handling);
+		VSB_printf(pan_vsp, "  VCL::return = 0x%x,\n", wrk->handling);
 	VSB_printf(pan_vsp, "  },\n");
 }
 
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 723da03..0ebf91a 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -65,10 +65,10 @@ static struct vcls		*vcl_active; /* protected by vcl_mtx */
 /*--------------------------------------------------------------------*/
 
 const char *
-VCL_Return_Name(unsigned method)
+VCL_Return_Name(unsigned r)
 {
 
-	switch (method) {
+	switch (r) {
 #define VCL_RET_MAC(l, U, B) case VCL_RET_##U: return(#l);
 #include "tbl/vcl_returns.h"
 #undef VCL_RET_MAC
@@ -77,6 +77,19 @@ VCL_Return_Name(unsigned method)
 	}
 }
 
+const char *
+VCL_Method_Name(unsigned m)
+{
+
+	switch (m) {
+#define VCL_MET_MAC(func, upper, bitmap) case VCL_MET_##upper: return (#upper);
+#include "tbl/vcl_returns.h"
+#undef VCL_MET_MAC
+	default:
+		return (NULL);
+	}
+}
+
 /*--------------------------------------------------------------------*/
 
 static void
@@ -346,12 +359,12 @@ VCL_##func##_method(struct worker *wrk, struct req *req, struct ws *ws)	\
 	AN(req->sp);							\
 	aws = WS_Snapshot(wrk->aws);					\
 	wrk->handling = 0;						\
-	req->cur_method = VCL_MET_ ## upper;				\
+	wrk->cur_method = VCL_MET_ ## upper;				\
 	VSLb(req->vsl, SLT_VCL_call, "%s", #func);			\
 	(void)req->vcl->func##_func(wrk, req, NULL, ws);		\
 	VSLb(req->vsl, SLT_VCL_return, "%s",				\
 	    VCL_Return_Name(wrk->handling));				\
-	req->cur_method = 0;						\
+	wrk->cur_method = 0;						\
 	assert((1U << wrk->handling) & bitmap);				\
 	assert(!((1U << wrk->handling) & ~bitmap));			\
 	WS_Reset(wrk->aws, aws);					\
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 622d6c8..7ea7bcb 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -487,13 +487,14 @@ VRT_CacheReqBody(struct req *req, long long maxsize)
  */
 
 void
-VRT_purge(struct req *req, double ttl, double grace)
+VRT_purge(const struct worker *wrk, struct req *req, double ttl, double grace)
 {
 
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-	if (req->cur_method == VCL_MET_LOOKUP)
+	if (wrk->cur_method == VCL_MET_LOOKUP)
 		HSH_Purge(req, req->obj->objcore->objhead, ttl, grace);
-	else if (req->cur_method == VCL_MET_MISS)
+	else if (wrk->cur_method == VCL_MET_MISS)
 		HSH_Purge(req, req->objcore->objhead, ttl, grace);
 }
 
diff --git a/bin/varnishtest/tests/c00033.vtc b/bin/varnishtest/tests/c00033.vtc
index a7782a1..f78b582 100644
--- a/bin/varnishtest/tests/c00033.vtc
+++ b/bin/varnishtest/tests/c00033.vtc
@@ -25,13 +25,13 @@ varnish v1 -vcl+backend {
 
 	sub vcl_lookup {
 		if (req.method == "PURGE") {
-			C{ VRT_purge(req, 0, 0); }C
+			C{ VRT_purge(wrk, req, 0, 0); }C
 			error 456 "got it";
 		}
 	}
 	sub vcl_miss {
 		if (req.method == "PURGE") {
-			C{ VRT_purge(req, 0, 0); }C
+			C{ VRT_purge(wrk, req, 0, 0); }C
 			error 456 "got it";
 		}
 	}
diff --git a/include/vrt.h b/include/vrt.h
index 1b4d189..e71308a 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -170,7 +170,7 @@ const char *VRT_regsub(struct req *, int all, const char *,
     void *, const char *);
 
 void VRT_ban_string(const char *);
-void VRT_purge(struct req *, double ttl, double grace);
+void VRT_purge(const struct worker *, struct req *, double ttl, double grace);
 
 void VRT_count(struct req *, unsigned);
 int VRT_rewrite(const char *, const char *);
diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c
index baa5f29..bb42e35 100644
--- a/lib/libvcl/vcc_action.c
+++ b/lib/libvcl/vcc_action.c
@@ -347,7 +347,7 @@ parse_purge(struct vcc *tl)
 {
 
 	vcc_NextToken(tl);
-	Fb(tl, 1, "VRT_purge(req, 0, 0);\n");
+	Fb(tl, 1, "VRT_purge(wrk, req, 0, 0);\n");
 }
 
 /*--------------------------------------------------------------------*/



More information about the varnish-commit mailing list