Commit 57359c50 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give VDP->init() vdp_ctx arg instead of req

parent dfaa9703
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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)
......
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