Commit a5e70172 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move cur_method from req to wrk

parent 20a5abe7
......@@ -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 *);
......
......@@ -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");
}
......
......@@ -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); \
......
......@@ -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);
}
......
......@@ -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";
}
}
......
......@@ -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 *);
......
......@@ -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");
}
/*--------------------------------------------------------------------*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment