[master] 57359c500 Give VDP->init() vdp_ctx arg instead of req
Poul-Henning Kamp
phk at FreeBSD.org
Mon Oct 26 20:07:09 UTC 2020
commit 57359c500d293189dfba11a19b64d02989dca8ae
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Oct 26 19:50:50 2020 +0000
Give VDP->init() vdp_ctx arg instead of req
diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index 65bcc6ff6..a8951305c 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -141,7 +141,7 @@ VDP_Push(struct req *req, const struct vdp *vdp, void *priv)
AZ(vdc->retval);
if (vdpe->vdp->init != NULL)
- vdc->retval = vdpe->vdp->init(req, &vdpe->priv);
+ vdc->retval = vdpe->vdp->init(vdc, &vdpe->priv);
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 43ebe9bf0..242cd19dc 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -254,15 +254,18 @@ ved_decode_len(struct vsl_log *vsl, const uint8_t **pp)
*/
static int v_matchproto_(vdp_init_f)
-ved_vdp_esi_init(struct req *req, void **priv)
+ved_vdp_esi_init(struct vdp_ctx *vdc, void **priv)
{
struct ecx *ecx;
+ struct req *req;
+ CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
+ req = vdc->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
AN(priv);
AZ(*priv);
- if (!ObjHasAttr(req->wrk, req->objcore, OA_ESIDATA))
+ if (!ObjHasAttr(vdc->wrk, req->objcore, OA_ESIDATA))
return (1);
ALLOC_OBJ(ecx, ECX_MAGIC);
@@ -584,26 +587,29 @@ struct ved_foo {
};
static int v_matchproto_(vdp_fini_f)
-ved_gzgz_init(struct req *req, void **priv)
+ved_gzgz_init(struct vdp_ctx *vdc, void **priv)
{
ssize_t l;
const char *p;
struct ved_foo *foo;
+ struct req *req;
+ CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
+ req = vdc->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CAST_OBJ_NOTNULL(foo, *priv, VED_FOO_MAGIC);
memset(foo->tailbuf, 0xdd, sizeof foo->tailbuf);
- AN(ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED));
+ AN(ObjCheckFlag(vdc->wrk, req->objcore, OF_GZIPED));
- p = ObjGetAttr(req->wrk, req->objcore, OA_GZIPBITS, &l);
+ p = ObjGetAttr(vdc->wrk, req->objcore, OA_GZIPBITS, &l);
AN(p);
assert(l == 32);
foo->start = vbe64dec(p);
foo->last = vbe64dec(p + 8);
foo->stop = vbe64dec(p + 16);
- foo->olen = ObjGetLen(req->wrk, req->objcore);
+ foo->olen = ObjGetLen(vdc->wrk, req->objcore);
assert(foo->start > 0 && foo->start < foo->olen * 8);
assert(foo->last > 0 && foo->last < foo->olen * 8);
assert(foo->stop > 0 && foo->stop < foo->olen * 8);
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 4ab1ca74e..e83706951 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 req *, void **priv);
+typedef int vdp_init_f(struct vdp_ctx *, void **priv);
/*
* Return value:
* negative: Error - abandon delivery
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 67bbc69f2..147fe67f0 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -288,15 +288,18 @@ 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 req *req, void **priv)
+vdp_gunzip_init(struct vdp_ctx *vdp, void **priv)
{
struct vgz *vg;
struct boc *boc;
+ struct req *req;
enum boc_state_e bos;
const char *p;
ssize_t dl;
uint64_t u;
+ CHECK_OBJ_NOTNULL(vdp, VDP_CTX_MAGIC);
+ req = vdp->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c
index a5516ae7d..016a95f90 100644
--- a/bin/varnishd/cache/cache_range.c
+++ b/bin/varnishd/cache/cache_range.c
@@ -243,29 +243,31 @@ vrg_ifrange(struct req *req)
}
static int v_matchproto_(vdp_init_f)
-vrg_range_init(struct req *req, void **priv)
+vrg_range_init(struct vdp_ctx *vdc, void **priv)
{
const char *r;
const char *err;
- assert(http_GetHdr(req->http, H_Range, &r));
- if (!vrg_ifrange(req)) // rfc7233,l,455,456
+ CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
+ CHECK_OBJ_NOTNULL(vdc->req, REQ_MAGIC);
+ assert(http_GetHdr(vdc->req->http, H_Range, &r));
+ if (!vrg_ifrange(vdc->req)) // rfc7233,l,455,456
return (1);
- err = vrg_dorange(req, r, priv);
+ err = vrg_dorange(vdc->req, r, priv);
if (err == NULL)
return (*priv == NULL ? 1 : 0);
- VSLb(req->vsl, SLT_Debug, "RANGE_FAIL %s", err);
- if (req->resp_len >= 0)
- http_PrintfHeader(req->resp,
+ VSLb(vdc->vsl, SLT_Debug, "RANGE_FAIL %s", err);
+ if (vdc->req->resp_len >= 0)
+ http_PrintfHeader(vdc->req->resp,
"Content-Range: bytes */%jd",
- (intmax_t)req->resp_len);
- http_PutResponse(req->resp, "HTTP/1.1", 416, NULL);
+ (intmax_t)vdc->req->resp_len);
+ http_PutResponse(vdc->req->resp, "HTTP/1.1", 416, NULL);
/*
* XXX: We ought to produce a body explaining things.
* XXX: That really calls for us to hit vcl_synth{}
*/
- req->resp_len = 0;
+ vdc->req->resp_len = 0;
return (1);
}
diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c
index 4ead4dcd3..729fd6bec 100644
--- a/bin/varnishd/http2/cache_http2_deliver.c
+++ b/bin/varnishd/http2/cache_http2_deliver.c
@@ -75,10 +75,12 @@ V2D_Init(void)
/**********************************************************************/
static int v_matchproto_(vdp_init_f)
-h2_init(struct req *req, void **priv)
+h2_init(struct vdp_ctx *vdc, void **priv)
{
- *priv = req->transport_priv;
+ CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
+ CHECK_OBJ_NOTNULL(vdc->req, REQ_MAGIC);
+ *priv = vdc->req->transport_priv;
return (0);
}
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index aacebc4d9..44afe6098 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -101,9 +101,9 @@ static const struct vfp xyzzy_rot13 = {
#define ROT13_BUFSZ 8
static int v_matchproto_(vdp_init_f)
-xyzzy_rot13_init(struct req *req, void **priv)
+xyzzy_rot13_init(struct vdp_ctx *vdc, void **priv)
{
- (void)req;
+ (void)vdc;
AN(priv);
*priv = malloc(ROT13_BUFSZ);
if (*priv == NULL)
More information about the varnish-commit
mailing list