[master] 72a8e80 Make the req.body iterator use same prototype as obj iterator
Poul-Henning Kamp
phk at FreeBSD.org
Thu Dec 10 10:07:51 CET 2015
commit 72a8e80c33056b6141b991f2e4faf94cff6ce60d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Dec 10 09:07:29 2015 +0000
Make the req.body iterator use same prototype as obj iterator
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 10019bf..dc2d72e 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -682,8 +682,7 @@ void VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want);
/* cache_req_body.c */
int VRB_Ignore(struct req *req);
ssize_t VRB_Cache(struct req *req, ssize_t maxsize);
-typedef int (req_body_iter_f)(struct req *, void *priv,
- const void *ptr, size_t);
+typedef int req_body_iter_f(void *priv, int flush, const void *ptr, ssize_t len);
ssize_t VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv);
void VRB_Free(struct req *req);
diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c
index 36256c9..4f4d2af 100644
--- a/bin/varnishd/cache/cache_req_body.c
+++ b/bin/varnishd/cache/cache_req_body.c
@@ -56,16 +56,15 @@ struct vrb_foo {
ssize_t ll;
};
-static int
+static int __match_proto__(objiterate_f)
vrb_objiterator(void *priv, int flush, const void *ptr, ssize_t len)
{
struct vrb_foo *foo;
CAST_OBJ_NOTNULL(foo, priv, VRB_FOO_MAGIC);
- (void)flush;
foo->ll += len;
- return (foo->func(foo->req, foo->priv, ptr, len));
+ return (foo->func(foo->priv, flush, ptr, len));
}
ssize_t
@@ -144,7 +143,7 @@ VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv)
req->req_bodybytes += l;
req->acct.req_bodybytes += l;
ll += l;
- l = func(req, priv, buf, l);
+ l = func(priv, 1, buf, l);
if (l) {
req->req_body_status = REQ_BODY_FAIL;
ll = -1;
@@ -165,11 +164,11 @@ VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv)
*/
static int __match_proto__(req_body_iter_f)
-httpq_req_body_discard(struct req *req, void *priv, const void *ptr, size_t len)
+httpq_req_body_discard(void *priv, int flush, const void *ptr, ssize_t len)
{
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
(void)priv;
+ (void)flush;
(void)ptr;
(void)len;
return (0);
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 0a7f100..4659c54 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -49,16 +49,15 @@
*/
static int __match_proto__(req_body_iter_f)
-vbf_iter_req_body(struct req *req, void *priv, const void *ptr, size_t l)
+vbf_iter_req_body(void *priv, int flush, const void *ptr, ssize_t l)
{
struct busyobj *bo;
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
if (l > 0) {
bo->acct.bereq_bodybytes += V1L_Write(bo->wrk, ptr, l);
- if (V1L_Flush(bo->wrk))
+ if (flush && V1L_Flush(bo->wrk))
return (-1);
}
return (0);
More information about the varnish-commit
mailing list