[master] 530dc80fb vcl: New beresp.transit_buffer variable

Nils Goroll nils.goroll at uplex.de
Mon Nov 7 14:57:06 UTC 2022


commit 530dc80fb22b9eeebacab45230494c8caccf9919
Author: Alf-André Walla <fwsgonzo at hotmail.com>
Date:   Tue Dec 7 13:22:35 2021 +0100

    vcl: New beresp.transit_buffer variable
    
    To override the global parameter on a per-fetch basis.
    
    Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>

diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index 97e74b9bf..fe4f8a81e 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -303,6 +303,36 @@ VRT_r_beresp_uncacheable(VRT_CTX)
 
 /*--------------------------------------------------------------------*/
 
+VCL_BYTES
+VRT_r_beresp_transit_buffer(VRT_CTX)
+{
+    struct objcore *oc;
+
+    CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+    CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
+
+    oc = ctx->bo->fetch_objcore;
+    CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+
+    return oc->boc->transit_buffer;
+}
+
+VCL_VOID
+VRT_l_beresp_transit_buffer(VRT_CTX, VCL_BYTES value)
+{
+    struct objcore *oc;
+
+    CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+    CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
+
+    oc = ctx->bo->fetch_objcore;
+    CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+
+    oc->boc->transit_buffer = value;
+}
+
+/*--------------------------------------------------------------------*/
+
 VCL_STRING
 VRT_r_client_identity(VRT_CTX)
 {
diff --git a/bin/varnishtest/tests/c00112.vtc b/bin/varnishtest/tests/c00112.vtc
index 491daedee..5ad76ac84 100644
--- a/bin/varnishtest/tests/c00112.vtc
+++ b/bin/varnishtest/tests/c00112.vtc
@@ -11,7 +11,6 @@ server s2 {
 	txresp -bodylen 2000000
 } -start
 
-varnish v1 -cliok "param.set transit_buffer 1k"
 varnish v1 -vcl+backend {
 	sub vcl_recv {
 		set req.backend_hint = s2;
@@ -19,6 +18,9 @@ varnish v1 -vcl+backend {
 			set req.backend_hint = s1;
 		}
 	}
+	sub vcl_backend_response {
+		set beresp.transit_buffer = 1k;
+	}
 	sub vcl_deliver {
 		if (req.restarts < 1) {
 			return (restart);
diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst
index bf307edd2..361801fe0 100644
--- a/doc/sphinx/reference/vcl_var.rst
+++ b/doc/sphinx/reference/vcl_var.rst
@@ -1059,6 +1059,17 @@ beresp.time
 	``vcl_backend_response {}`` was entered, or when
 	``vcl_backend_error {}`` was entered.
 
+beresp.transit_buffer
+
+	Type: BYTES
+
+	Readable from: vcl_backend_response
+
+	Writable from: vcl_backend_response
+
+	The maximum number of bytes the client can be ahead of the
+	backend during a streaming pass if ``beresp`` is uncacheable.
+
 
 beresp.ttl
 


More information about the varnish-commit mailing list