[6.0] b0371af3e Make two functions to get from req/bo to VRT_CTX
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Thu Aug 16 08:52:52 UTC 2018
commit b0371af3e53ae4a60555164286cd3c9c2a1763cf
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue May 1 07:37:27 2018 +0000
Make two functions to get from req/bo to VRT_CTX
Conflicts:
bin/varnishd/cache/cache_director.c
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index 9283ba433..111c6530f 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -388,6 +388,9 @@ void VCL_Refresh(struct vcl **);
void VCL_Rel(struct vcl **);
const char *VCL_Return_Name(unsigned);
const char *VCL_Method_Name(unsigned);
+void VCL_Bo2Ctx(struct vrt_ctx *, struct busyobj *);
+void VCL_Req2Ctx(struct vrt_ctx *, struct req *);
+
#define VCL_MET_MAC(l,u,t,b) \
void VCL_##l##_method(struct vcl *, struct worker *, struct req *, \
struct busyobj *bo, void *specific);
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index abc519f39..98cc47dec 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -69,6 +69,42 @@ static uintptr_t ws_snapshot_cli;
/*--------------------------------------------------------------------*/
+void
+VCL_Bo2Ctx(struct vrt_ctx *ctx, struct busyobj *bo)
+{
+
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+ ctx->vcl = bo->vcl;
+ ctx->vsl = bo->vsl;
+ ctx->http_bereq = bo->bereq;
+ ctx->http_beresp = bo->beresp;
+ ctx->bo = bo;
+ ctx->sp = bo->sp;
+ ctx->now = bo->t_prev;
+ ctx->ws = bo->ws;
+}
+
+void
+VCL_Req2Ctx(struct vrt_ctx *ctx, struct req *req)
+{
+
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+
+ ctx->vcl = req->vcl;
+ ctx->vsl = req->vsl;
+ ctx->http_req = req->http;
+ ctx->http_req_top = req->top->http;
+ ctx->http_resp = req->resp;
+ ctx->req = req;
+ ctx->sp = req->sp;
+ ctx->now = req->t_prev;
+ ctx->ws = req->ws;
+}
+
+/*--------------------------------------------------------------------*/
+
static struct vrt_ctx *
vcl_get_ctx(unsigned method, int msg)
{
diff --git a/bin/varnishd/cache/cache_vcl_vrt.c b/bin/varnishd/cache/cache_vcl_vrt.c
index 484c14b4a..f040f9027 100644
--- a/bin/varnishd/cache/cache_vcl_vrt.c
+++ b/bin/varnishd/cache/cache_vcl_vrt.c
@@ -340,7 +340,6 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
void *specific, unsigned method, vcl_func_f *func)
{
uintptr_t aws;
- struct vsl_log *vsl = NULL;
struct vrt_ctx ctx;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
@@ -349,33 +348,17 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(req->vcl, VCL_MAGIC);
- vsl = req->vsl;
- ctx.vcl = req->vcl;
- ctx.http_req = req->http;
- ctx.http_req_top = req->top->http;
- ctx.http_resp = req->resp;
- ctx.req = req;
- ctx.sp = req->sp;
- ctx.now = req->t_prev;
- ctx.ws = req->ws;
+ VCL_Req2Ctx(&ctx, req);
}
if (bo != NULL) {
if (req)
assert(method == VCL_MET_PIPE);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(bo->vcl, VCL_MAGIC);
- vsl = bo->vsl;
- ctx.vcl = bo->vcl;
- ctx.http_bereq = bo->bereq;
- ctx.http_beresp = bo->beresp;
- ctx.bo = bo;
- ctx.sp = bo->sp;
- ctx.now = bo->t_prev;
- ctx.ws = bo->ws;
+ VCL_Bo2Ctx(&ctx, bo);
}
assert(ctx.now != 0);
ctx.syntax = ctx.vcl->conf->syntax;
- ctx.vsl = vsl;
ctx.specific = specific;
ctx.method = method;
wrk->handling = 0;
@@ -383,10 +366,10 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
aws = WS_Snapshot(wrk->aws);
wrk->cur_method = method;
wrk->seen_methods |= method;
- AN(vsl);
- VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method));
+ AN(ctx.vsl);
+ VSLb(ctx.vsl, SLT_VCL_call, "%s", VCL_Method_Name(method));
func(&ctx);
- VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling));
+ VSLb(ctx.vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling));
wrk->cur_method |= 1; // Magic marker
if (wrk->handling == VCL_RET_FAIL)
wrk->stats->vcl_fail++;
More information about the varnish-commit
mailing list