[master] 4c5293804 boc: Set up transit buffer only for a backend fetch
Walid Boudebouda
walid.boudebouda at gmail.com
Wed Jul 30 14:02:06 UTC 2025
commit 4c529380490df08be2f943d506ad034c158700a0
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Fri Jul 11 09:32:03 2025 +0200
boc: Set up transit buffer only for a backend fetch
It can otherwise lock up a client request body fetch indefinitely. An
early setup at BOC creation time also increases the gap between updates
to the transit_buffer parameter and its effectiveness, since BOCs can be
created early through objcore preallocation made by worker threads.
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 0521d0314..0b3685e45 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -1175,6 +1175,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
boc = HSH_RefBoc(oc);
CHECK_OBJ_NOTNULL(boc, BOC_MAGIC);
+ boc->transit_buffer = cache_param->transit_buffer;
switch (mode) {
case VBF_PASS:
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index dfc7929a0..c85ecd618 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -109,7 +109,6 @@ obj_newboc(void)
Lck_New(&boc->mtx, lck_busyobj);
PTOK(pthread_cond_init(&boc->cond, NULL));
boc->refcount = 1;
- boc->transit_buffer = cache_param->transit_buffer;
return (boc);
}
diff --git a/bin/varnishtest/tests/r04362.vtc b/bin/varnishtest/tests/r04362.vtc
new file mode 100644
index 000000000..3ca74e72e
--- /dev/null
+++ b/bin/varnishtest/tests/r04362.vtc
@@ -0,0 +1,24 @@
+varnishtest "No transit buffer for req.body and vcl_synth"
+
+varnish v1 -cliok "param.set transit_buffer 4k"
+varnish v1 -vcl {
+ import std;
+
+ backend be none;
+
+ sub vcl_recv {
+ if (!std.cache_req_body(10MB)) {
+ return (synth(503));
+ }
+ return (synth(200));
+ }
+} -start
+
+client c1 {
+ txreq -bodylen 10240
+ rxresp
+ expect resp.status == 200
+} -run
+
+varnish v1 -expect transit_stored > 10240
+varnish v1 -expect transit_buffered == 0
More information about the varnish-commit
mailing list