[master] 54e569239 debug storage: Clarify single instance use and document why

Nils Goroll nils.goroll at uplex.de
Fri Apr 11 10:52:09 UTC 2025


commit 54e569239d3751c3c81e1eefeebd92cfabf9fb2f
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Fri Apr 11 11:27:22 2025 +0200

    debug storage: Clarify single instance use and document why

diff --git a/bin/varnishd/storage/storage_debug.c b/bin/varnishd/storage/storage_debug.c
index f2500d8ed..bf4a01a43 100644
--- a/bin/varnishd/storage/storage_debug.c
+++ b/bin/varnishd/storage/storage_debug.c
@@ -34,6 +34,7 @@
 
 #include "cache/cache_varnishd.h"
 #include "cache/cache_obj.h"
+#include "common/heritage.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -44,12 +45,13 @@
 #include "vtim.h"
 #include "vnum.h"
 
-/* we cheat and make the open delay a static to avoid
- * having to wrap all callbacks to unpack the priv
- * pointer. Consequence: last dopen applies to all
- * debug stevedores
+/*
+ * if smd was to have its own configuration, we would have to wrap all function
+ * pointers from the actual storage implementation (sma). To avoid these
+ * complications, we limit to one smd instance and use statics.
  */
 static vtim_dur dopen = 0.0;
+static unsigned count = 0;
 
 /* returns one byte less than requested */
 static int v_matchproto_(objgetspace_f)
@@ -85,6 +87,9 @@ smd_init(struct stevedore *parent, int aac, char * const *aav)
 	char **av;	//lint -e429
 	char *a;
 
+	if (count++ > 0)
+		ARGV_ERR("Only one -s%s instance supported\n", smd_stevedore.name);
+
 	ident = parent->ident;
 	memcpy(parent, &sma_stevedore, sizeof *parent);
 	parent->ident = ident;
diff --git a/bin/varnishtest/tests/c00030.vtc b/bin/varnishtest/tests/c00030.vtc
new file mode 100644
index 000000000..912337dbf
--- /dev/null
+++ b/bin/varnishtest/tests/c00030.vtc
@@ -0,0 +1,4 @@
+varnishtest "debug storage"
+
+shell -err -expect {Error: Only one -sdebug instance supported} \
+	"varnishd -b none -a ${tmpdir}/vtc.sock -sdebug -sdebug"


More information about the varnish-commit mailing list