[master] 1a818d8bc Pass the objcore to (only!) the topmost VDP
Poul-Henning Kamp
phk at FreeBSD.org
Mon Nov 2 10:47:09 UTC 2020
commit 1a818d8bc460c372aa144499d8075693fd70740d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Nov 2 10:45:47 2020 +0000
Pass the objcore to (only!) the topmost VDP
diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index a23ccec92..85d294b2d 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -166,8 +166,14 @@ VDP_Push(struct vdp_ctx *vdc, struct ws *ws, const struct vdp *vdp, void *priv)
vdc->nxt = VTAILQ_FIRST(&vdc->vdp);
AZ(vdc->retval);
- if (vdpe->vdp->init != NULL)
- vdc->retval = vdpe->vdp->init(vdc, &vdpe->priv);
+ if (vdpe->vdp->init == NULL)
+ return (vdc->retval);
+
+ vdc->retval = vdpe->vdp->init(
+ vdc,
+ &vdpe->priv,
+ vdpe == vdc->nxt ? vdc->req->objcore : NULL
+ );
if (vdc->retval > 0) {
VTAILQ_REMOVE(&vdc->vdp, vdpe, list);
vdc->nxt = VTAILQ_FIRST(&vdc->vdp);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index cd4755e19..caed6f30c 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -254,20 +254,21 @@ ved_decode_len(struct vsl_log *vsl, const uint8_t **pp)
*/
static int v_matchproto_(vdp_init_f)
-ved_vdp_esi_init(struct vdp_ctx *vdc, void **priv)
+ved_vdp_esi_init(struct vdp_ctx *vdc, void **priv, struct objcore *oc)
{
struct ecx *ecx;
struct req *req;
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
+ CHECK_OBJ_ORNULL(oc, OBJCORE_MAGIC);
+ if (oc == NULL || !ObjHasAttr(vdc->wrk, oc, OA_ESIDATA))
+ return (1);
+
req = vdc->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
AN(priv);
AZ(*priv);
- if (!ObjHasAttr(vdc->wrk, req->objcore, OA_ESIDATA))
- return (1);
-
ALLOC_OBJ(ecx, ECX_MAGIC);
AN(ecx);
assert(sizeof gzip_hdr == 10);
@@ -587,7 +588,7 @@ struct ved_foo {
};
static int v_matchproto_(vdp_fini_f)
-ved_gzgz_init(struct vdp_ctx *vdc, void **priv)
+ved_gzgz_init(struct vdp_ctx *vdc, void **priv, struct objcore *oc)
{
ssize_t l;
const char *p;
@@ -595,6 +596,7 @@ ved_gzgz_init(struct vdp_ctx *vdc, void **priv)
struct req *req;
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
+ (void)oc;
req = vdc->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CAST_OBJ_NOTNULL(foo, *priv, VED_FOO_MAGIC);
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index ff07ac563..451c5715b 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -102,7 +102,7 @@ enum vdp_action {
VDP_END, /* Last buffer or after, implies VDP_FLUSH */
};
-typedef int vdp_init_f(struct vdp_ctx *, void **priv);
+typedef int vdp_init_f(struct vdp_ctx *, void **priv, struct objcore *);
/*
* Return value:
* negative: Error - abandon delivery
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 147fe67f0..7e98ff4d9 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -288,7 +288,7 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, ssize_t *plen, enum vgz_flag flags)
*/
static int v_matchproto_(vdp_init_f)
-vdp_gunzip_init(struct vdp_ctx *vdp, void **priv)
+vdp_gunzip_init(struct vdp_ctx *vdp, void **priv, struct objcore *oc)
{
struct vgz *vg;
struct boc *boc;
@@ -299,9 +299,9 @@ vdp_gunzip_init(struct vdp_ctx *vdp, void **priv)
uint64_t u;
CHECK_OBJ_NOTNULL(vdp, VDP_CTX_MAGIC);
+ CHECK_OBJ_ORNULL(oc, OBJCORE_MAGIC);
req = vdp->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
vg = VGZ_NewGunzip(req->vsl, "U D -");
AN(vg);
@@ -317,27 +317,22 @@ vdp_gunzip_init(struct vdp_ctx *vdp, void **priv)
req->resp_len = -1;
- boc = HSH_RefBoc(req->objcore);
+ if (oc == NULL)
+ return (0);
+
+ boc = HSH_RefBoc(oc);
if (boc != NULL) {
CHECK_OBJ(boc, BOC_MAGIC);
bos = boc->state;
- HSH_DerefBoc(req->wrk, req->objcore);
- } else
- bos = BOS_FINISHED;
-
- /* OA_GZIPBITS is not stable yet */
- if (bos < BOS_FINISHED)
- return (0);
+ HSH_DerefBoc(req->wrk, oc);
+ if (bos < BOS_FINISHED)
+ return (0); /* OA_GZIPBITS is not stable yet */
+ }
- p = ObjGetAttr(req->wrk, req->objcore, OA_GZIPBITS, &dl);
+ p = ObjGetAttr(req->wrk, oc, OA_GZIPBITS, &dl);
if (p != NULL && dl == 32) {
u = vbe64dec(p + 24);
- /*
- * If the size is non-zero AND we are the top VDP
- * (ie: no ESI), we know what size the output will be.
- */
- if (u != 0 &&
- VTAILQ_FIRST(&req->vdc->vdp)->vdp == &VDP_gunzip)
+ if (u != 0)
req->resp_len = u;
}
return (0);
diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c
index b705cd526..007cf2c74 100644
--- a/bin/varnishd/cache/cache_range.c
+++ b/bin/varnishd/cache/cache_range.c
@@ -244,13 +244,14 @@ vrg_ifrange(struct req *req)
}
static int v_matchproto_(vdp_init_f)
-vrg_range_init(struct vdp_ctx *vdc, void **priv)
+vrg_range_init(struct vdp_ctx *vdc, void **priv, struct objcore *oc)
{
const char *r;
const char *err;
struct req *req;
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
+ (void)oc;
req = vdc->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
assert(http_GetHdr(req->http, H_Range, &r));
diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c
index 4ee707816..55a66290f 100644
--- a/bin/varnishd/http2/cache_http2_deliver.c
+++ b/bin/varnishd/http2/cache_http2_deliver.c
@@ -75,10 +75,11 @@ V2D_Init(void)
/**********************************************************************/
static int v_matchproto_(vdp_init_f)
-h2_init(struct vdp_ctx *vdc, void **priv)
+h2_init(struct vdp_ctx *vdc, void **priv, struct objcore *oc)
{
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
+ (void)oc;
CHECK_OBJ_NOTNULL(vdc->req, REQ_MAGIC);
*priv = vdc->req->transport_priv;
return (0);
More information about the varnish-commit
mailing list