[master] 563c7380f Replace DBG_SLOW_BEREQ
Nils Goroll
nils.goroll at uplex.de
Mon Sep 30 14:19:07 UTC 2024
commit 563c7380faca2d74544fc75e3c920a5c905131dd
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Sep 6 17:42:25 2024 +0200
Replace DBG_SLOW_BEREQ
diff --git a/bin/varnishtest/tests/m00048.vtc b/bin/varnishtest/tests/m00048.vtc
index 6e4263224..bcd94925a 100644
--- a/bin/varnishtest/tests/m00048.vtc
+++ b/bin/varnishtest/tests/m00048.vtc
@@ -66,7 +66,7 @@ varnish v1 -vcl+backend {
sub vcl_deliver {
if (req.http.Rot13) {
- set resp.filters = "rot13 debug.pedantic";
+ set resp.filters = "debug.slow rot13 debug.pedantic";
}
}
}
@@ -90,7 +90,7 @@ varnish v1 -vcl {
sub vcl_synth {
set resp.body = "Ponto Facto, Caesar Transit!";
if (req.http.Rot13) {
- set resp.filters += "rot13 debug.chunked debug.pedantic";
+ set resp.filters += "debug.slow rot13 debug.chunked debug.pedantic";
}
return (deliver);
}
diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h
index cbe11a487..2c6a980c4 100644
--- a/include/tbl/debug_bits.h
+++ b/include/tbl/debug_bits.h
@@ -52,7 +52,6 @@ DEBUG_BIT(PROCESSORS, processors, "Fetch/Deliver processors")
DEBUG_BIT(PROTOCOL, protocol, "Protocol debugging")
DEBUG_BIT(VCL_KEEP, vcl_keep, "Keep VCL C and so files")
DEBUG_BIT(LCK, lck, "Additional lock statistics")
-DEBUG_BIT(SLOW_BEREQ, slow_bereq, "Slow down bereq") // XXX -> filter
#undef DEBUG_BIT
/*lint -restore */
diff --git a/vmod/vmod_debug.c b/vmod/vmod_debug.c
index 3cf1eb7b7..33c1bf45e 100644
--- a/vmod/vmod_debug.c
+++ b/vmod/vmod_debug.c
@@ -322,6 +322,46 @@ static const struct vdp xyzzy_vdp_pedantic = {
.fini = xyzzy_pedantic_fini,
};
+/**********************************************************************
+ *
+ * this trivial copy/paste/edit filter (of rot13) was specifically made for
+ * someone who added a DBG_SLOW_BEREQ debug flag. It should actually be turned
+ * in a proper "bandwidth control" filter, but that exceeds an evening's work,
+ * so it's kept for later
+ */
+
+static enum vfp_status v_matchproto_(vfp_pull_f)
+xyzzy_vfp_slow_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p,
+ ssize_t *lp)
+{
+
+ (void)vfe;
+ VTIM_sleep(1.0);
+ return (VFP_Suck(vc, p, lp));
+}
+
+static const struct vfp xyzzy_vfp_slow = {
+ .name = "debug.slow",
+ .pull = xyzzy_vfp_slow_pull,
+};
+
+/**********************************************************************/
+
+static int v_matchproto_(vdp_bytes_f)
+xyzzy_vdp_slow_bytes(struct vdp_ctx *vdc, enum vdp_action act, void **priv,
+ const void *ptr, ssize_t len)
+{
+
+ (void)priv;
+ VTIM_sleep(1.0);
+ return (VDP_bytes(vdc, act, ptr, len));
+}
+
+static const struct vdp xyzzy_vdp_slow = {
+ .name = "debug.slow",
+ .bytes = xyzzy_vdp_slow_bytes
+};
+
/**********************************************************************/
VCL_STRING v_matchproto_(td_debug_author)
@@ -593,6 +633,7 @@ event_load(VRT_CTX, struct vmod_priv *priv)
AZ(VRT_AddFilter(ctx, &xyzzy_vfp_rot13, &xyzzy_vdp_rot13));
AZ(VRT_AddFilter(ctx, NULL, &xyzzy_vdp_pedantic));
AZ(VRT_AddFilter(ctx, NULL, &xyzzy_vdp_chunked));
+ AZ(VRT_AddFilter(ctx, &xyzzy_vfp_slow, &xyzzy_vdp_slow));
return (0);
}
@@ -754,6 +795,7 @@ event_discard(VRT_CTX, void *priv)
AZ(ctx->msg);
+ VRT_RemoveFilter(ctx, &xyzzy_vfp_slow, &xyzzy_vdp_slow);
VRT_RemoveFilter(ctx, &xyzzy_vfp_rot13, &xyzzy_vdp_rot13);
VRT_RemoveFilter(ctx, NULL, &xyzzy_vdp_pedantic);
VRT_RemoveFilter(ctx, NULL, &xyzzy_vdp_chunked);
More information about the varnish-commit
mailing list