[master] 11c6e33 Make space for VDP's to have a priv pointer
Poul-Henning Kamp
phk at FreeBSD.org
Tue Oct 21 23:15:13 CEST 2014
commit 11c6e33e4ab9292d9931e5f4c9485fec663c46c3
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Oct 21 21:14:57 2014 +0000
Make space for VDP's to have a priv pointer
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7705ea4..01d3ce8 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -616,6 +616,7 @@ struct req {
/* Deliver pipeline */
#define N_VDPS 5
vdp_bytes *vdps[N_VDPS];
+ void *vdpp[N_VDPS];
int vdp_nxt;
/* Range */
@@ -765,7 +766,7 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len)
/* Call the present layer, while pointing to the next layer down */
i = req->vdp_nxt--;
assert(i >= 0 && i < N_VDPS);
- retval = req->vdps[i](req, act, ptr, len);
+ retval = req->vdps[i](req, act, req->vdpp[i], ptr, len);
req->vdp_nxt++;
return (retval);
}
@@ -780,6 +781,9 @@ VDP_push(struct req *req, vdp_bytes *func)
assert(req->vdp_nxt >= 0);
assert(req->vdp_nxt + 1 < N_VDPS);
req->vdps[++req->vdp_nxt] = func;
+ req->vdpp[req->vdp_nxt] = NULL;
+ AZ(req->vdps[req->vdp_nxt](req, VDP_INIT,
+ &req->vdpp[req->vdp_nxt], NULL, 0));
}
static inline void
@@ -791,6 +795,10 @@ VDP_pop(struct req *req, vdp_bytes *func)
assert(req->vdp_nxt >= 1);
assert(req->vdp_nxt < N_VDPS);
assert(req->vdps[req->vdp_nxt] == func);
+ AZ(req->vdps[req->vdp_nxt](req, VDP_FINI,
+ &req->vdpp[req->vdp_nxt], NULL, 0));
+ AZ(req->vdpp[req->vdp_nxt]);
+ req->vdps[req->vdp_nxt] = NULL;
req->vdp_nxt--;
}
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index cfb488e..a126b53 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -206,15 +206,17 @@ ved_decode_len(uint8_t **pp)
*/
int __match_proto__(vdp_bytes)
-VED_pretend_gzip(struct req *req, enum vdp_action act, const void *pv,
- ssize_t l)
+VED_pretend_gzip(struct req *req, enum vdp_action act, void *priv,
+ const void *pv, ssize_t l)
{
uint8_t buf1[5], buf2[5];
const uint8_t *p;
uint16_t lx;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- (void)act;
+ (void)priv;
+ if (act == VDP_INIT || act == VDP_FINI)
+ return (0);
p = pv;
lx = 65535;
@@ -362,7 +364,7 @@ ESI_Deliver(struct req *req)
* was not gzip'ed.
*/
(void)VED_pretend_gzip(req, VDP_NULL,
- pp, l2);
+ NULL, pp, l2);
} else if (isgzip) {
/*
* A gzip'ed VEC, but ungzip'ed ESI
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index a5a705a..9377a89 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -72,9 +72,11 @@ enum vfp_status VFP_Error(struct vfp_ctx *, const char *fmt, ...)
/* Deliver processors ------------------------------------------------*/
enum vdp_action {
+ VDP_INIT,
VDP_NULL,
VDP_FLUSH,
VDP_FINISH,
+ VDP_FINI,
};
-typedef int vdp_bytes(struct req *, enum vdp_action, const void *ptr,
- ssize_t len);
+typedef int vdp_bytes(struct req *, enum vdp_action, void *priv,
+ const void *ptr, ssize_t len);
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 5e2125b..9e437bb 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -285,7 +285,8 @@ VGZ_WrwInit(struct vgz *vg)
*/
int __match_proto__(vdp_bytes)
-VDP_gunzip(struct req *req, enum vdp_action act, const void *ptr, ssize_t len)
+VDP_gunzip(struct req *req, enum vdp_action act, void *priv,
+ const void *ptr, ssize_t len)
{
enum vgzret_e vr;
ssize_t dl;
@@ -296,6 +297,9 @@ VDP_gunzip(struct req *req, enum vdp_action act, const void *ptr, ssize_t len)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
wrk = req->wrk;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+ (void)priv;
+ if (act == VDP_INIT || act == VDP_FINI)
+ return (0);
vg = req->vgz;
CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
AN(vg->m_buf);
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 70d61c7..b744350 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -36,11 +36,15 @@
/*--------------------------------------------------------------------*/
static int __match_proto__(vdp_bytes)
-v1d_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len)
+v1d_bytes(struct req *req, enum vdp_action act, void *priv,
+ const void *ptr, ssize_t len)
{
ssize_t wl = 0;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+ (void)priv;
+ if (act == VDP_INIT || act == VDP_FINI)
+ return (0);
assert(req->vdp_nxt == -1); /* always at the bottom of the pile */
@@ -57,14 +61,17 @@ v1d_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len)
/*--------------------------------------------------------------------*/
static int __match_proto__(vdp_bytes)
-v1d_range_bytes(struct req *req, enum vdp_action act, const void *ptr,
- ssize_t len)
+v1d_range_bytes(struct req *req, enum vdp_action act, void *priv,
+ const void *ptr, ssize_t len)
{
int retval = 0;
ssize_t l;
const char *p = ptr;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+ (void)priv;
+ if (act == VDP_INIT || act == VDP_FINI)
+ return (0);
l = req->range_low - req->range_off;
if (l > 0) {
if (l > len)
More information about the varnish-commit
mailing list