Skip to content

Commit fcf0ace

Browse files
committed
Replace DBG_SLOW_BEREQ
1 parent 8ebcaca commit fcf0ace

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

bin/varnishtest/tests/m00048.vtc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ varnish v1 -vcl+backend {
6666

6767
sub vcl_deliver {
6868
if (req.http.Rot13) {
69-
set resp.filters = "rot13 debug.pedantic";
69+
set resp.filters = "debug.slow rot13 debug.pedantic";
7070
}
7171
}
7272
}
@@ -90,7 +90,7 @@ varnish v1 -vcl {
9090
sub vcl_synth {
9191
set resp.body = "Ponto Facto, Caesar Transit!";
9292
if (req.http.Rot13) {
93-
set resp.filters += "rot13 debug.chunked debug.pedantic";
93+
set resp.filters += "debug.slow rot13 debug.chunked debug.pedantic";
9494
}
9595
return (deliver);
9696
}

include/tbl/debug_bits.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ DEBUG_BIT(PROCESSORS, processors, "Fetch/Deliver processors")
5252
DEBUG_BIT(PROTOCOL, protocol, "Protocol debugging")
5353
DEBUG_BIT(VCL_KEEP, vcl_keep, "Keep VCL C and so files")
5454
DEBUG_BIT(LCK, lck, "Additional lock statistics")
55-
DEBUG_BIT(SLOW_BEREQ, slow_bereq, "Slow down bereq") // XXX -> filter
5655
#undef DEBUG_BIT
5756

5857
/*lint -restore */

vmod/vmod_debug.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,46 @@ static const struct vdp xyzzy_vdp_pedantic = {
322322
.fini = xyzzy_pedantic_fini,
323323
};
324324

325+
/**********************************************************************
326+
*
327+
* this trivial copy/paste/edit filter (of rot13) was specifically made for
328+
* someone who added a DBG_SLOW_BEREQ debug flag. It should actually be turned
329+
* in a proper "bandwidth control" filter, but that exceeds an evening's work,
330+
* so it's kept for later
331+
*/
332+
333+
static enum vfp_status v_matchproto_(vfp_pull_f)
334+
xyzzy_vfp_slow_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p,
335+
ssize_t *lp)
336+
{
337+
338+
(void)vfe;
339+
VTIM_sleep(1.0);
340+
return (VFP_Suck(vc, p, lp));
341+
}
342+
343+
static const struct vfp xyzzy_vfp_slow = {
344+
.name = "debug.slow",
345+
.pull = xyzzy_vfp_slow_pull,
346+
};
347+
348+
/**********************************************************************/
349+
350+
static int v_matchproto_(vdp_bytes_f)
351+
xyzzy_vdp_slow_bytes(struct vdp_ctx *vdc, enum vdp_action act, void **priv,
352+
const void *ptr, ssize_t len)
353+
{
354+
355+
(void)priv;
356+
VTIM_sleep(1.0);
357+
return (VDP_bytes(vdc, act, ptr, len));
358+
}
359+
360+
static const struct vdp xyzzy_vdp_slow = {
361+
.name = "debug.slow",
362+
.bytes = xyzzy_vdp_slow_bytes
363+
};
364+
325365
/**********************************************************************/
326366

327367
VCL_STRING v_matchproto_(td_debug_author)
@@ -593,6 +633,7 @@ event_load(VRT_CTX, struct vmod_priv *priv)
593633
AZ(VRT_AddFilter(ctx, &xyzzy_vfp_rot13, &xyzzy_vdp_rot13));
594634
AZ(VRT_AddFilter(ctx, NULL, &xyzzy_vdp_pedantic));
595635
AZ(VRT_AddFilter(ctx, NULL, &xyzzy_vdp_chunked));
636+
AZ(VRT_AddFilter(ctx, &xyzzy_vfp_slow, &xyzzy_vdp_slow));
596637
return (0);
597638
}
598639

@@ -754,6 +795,7 @@ event_discard(VRT_CTX, void *priv)
754795

755796
AZ(ctx->msg);
756797

798+
VRT_RemoveFilter(ctx, &xyzzy_vfp_slow, &xyzzy_vdp_slow);
757799
VRT_RemoveFilter(ctx, &xyzzy_vfp_rot13, &xyzzy_vdp_rot13);
758800
VRT_RemoveFilter(ctx, NULL, &xyzzy_vdp_pedantic);
759801
VRT_RemoveFilter(ctx, NULL, &xyzzy_vdp_chunked);

0 commit comments

Comments
 (0)