[master] 4998fb2 Remove the debugging CLI commands to cache_panic.c where they belong
Poul-Henning Kamp
phk at FreeBSD.org
Wed Feb 25 15:30:15 CET 2015
commit 4998fb2e492e06b74ce2f9c0f1b66f8a843e356c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Feb 25 13:57:38 2015 +0000
Remove the debugging CLI commands to cache_panic.c where they belong
diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c
index c53d360..6bdf3f0 100644
--- a/bin/varnishd/cache/cache_cli.c
+++ b/bin/varnishd/cache/cache_cli.c
@@ -36,19 +36,14 @@
#include "config.h"
-#include <stddef.h> // offsetof
-
#include "cache.h"
#include "common/heritage.h"
#include "cache_backend.h" // struct vbc
-#include "hash/hash_slinger.h" // struct objhead
-#include "vsa.h"
#include "vcli.h"
#include "vcli_common.h"
#include "vcli_priv.h"
#include "vcli_serve.h"
-#include "storage/storage.h" // struct storage
pthread_t cli_thread;
static struct lock cli_mtx;
@@ -116,96 +111,9 @@ CLI_Run(void)
/*--------------------------------------------------------------------*/
-static void
-cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv)
-{
- (void)av;
- (void)priv;
-
-#define SZOF(foo) VCLI_Out(cli, \
- "sizeof(%s) = %zd = 0x%zx\n", #foo, sizeof(foo), sizeof(foo))
- SZOF(struct ws);
- SZOF(struct http);
- SZOF(struct http_conn);
- SZOF(struct acct_req);
- SZOF(struct worker);
- SZOF(struct wrk_accept);
- SZOF(struct storage);
- SZOF(struct busyobj);
- SZOF(struct object);
- SZOF(struct objcore);
- SZOF(struct objhead);
- SZOF(struct sess);
- SZOF(struct req);
- SZOF(struct vbc);
- SZOF(struct VSC_C_main);
- SZOF(struct lock);
- SZOF(struct dstat);
- VCLI_Out(cli, "sizeof(struct suckaddr) = %d = 0x%x\n",
- vsa_suckaddr_len, vsa_suckaddr_len);
-#if 0
-#define OFOF(foo, bar) { foo __foo; VCLI_Out(cli, \
- "%-30s = 0x%4zx @ 0x%4zx\n", \
- #foo "." #bar, sizeof(__foo.bar), offsetof(foo, bar)); }
-#if 0
- OFOF(struct objhead, magic);
- OFOF(struct objhead, refcnt);
- OFOF(struct objhead, mtx);
- OFOF(struct objhead, objcs);
- OFOF(struct objhead, digest);
- OFOF(struct objhead, waitinglist);
- OFOF(struct objhead, _u);
-#endif
-#if 0
- OFOF(struct http, magic);
- OFOF(struct http, logtag);
- OFOF(struct http, ws);
- OFOF(struct http, hd);
- OFOF(struct http, hdf);
- OFOF(struct http, shd);
- OFOF(struct http, nhd);
- OFOF(struct http, status);
- OFOF(struct http, protover);
- OFOF(struct http, conds);
-#endif
-#if 0
- OFOF(struct storage, magic);
- OFOF(struct storage, fd);
- OFOF(struct storage, where);
- OFOF(struct storage, list);
- OFOF(struct storage, stevedore);
- OFOF(struct storage, priv);
- OFOF(struct storage, ptr);
- OFOF(struct storage, len);
- OFOF(struct storage, space);
-#endif
-#undef OFOF
-#endif
-}
-
-/*--------------------------------------------------------------------*/
-
-static void
-ccf_panic(struct cli *cli, const char * const *av, void *priv)
-{
-
- (void)cli;
- (void)av;
- (void)priv;
- AZ(strcmp("", "You asked for it"));
-}
-
-/*--------------------------------------------------------------------*/
-
-static struct cli_proto master_cmds[] = {
+static struct cli_proto cli_cmds[] = {
{ CLI_PING, "i", VCLS_func_ping },
{ CLI_HELP, "i", VCLS_func_help },
- { "debug.sizeof", "debug.sizeof",
- "\tDump sizeof various data structures.",
- 0, 0, "d", cli_debug_sizeof },
- { "debug.panic.worker", "debug.panic.worker",
- "\tPanic the worker process.",
- 0, 0, "d", ccf_panic },
{ NULL }
};
@@ -224,5 +132,5 @@ CLI_Init(void)
&cache_param->cli_buffer, &cache_param->cli_limit);
AN(cls);
- CLI_AddFuncs(master_cmds);
+ CLI_AddFuncs(cli_cmds);
}
diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
index 469134d..3e5ebb6 100644
--- a/bin/varnishd/cache/cache_main.c
+++ b/bin/varnishd/cache/cache_main.c
@@ -211,8 +211,8 @@ child_main(void)
Lck_New(&vxid_lock, lck_vxid);
- PAN_Init();
CLI_Init();
+ PAN_Init();
VFP_Init();
Wait_Init();
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 193ac22..e04850b 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -36,18 +36,23 @@
#endif
#include <stdio.h>
+#include <stddef.h> // offsetof()
#include <stdlib.h>
#include <signal.h>
#include "cache.h"
#include "cache_filter.h"
+#include "hash/hash_slinger.h" // struct objhead
#include "vend.h"
#include "common/heritage.h"
#include "cache_backend.h"
#include "storage/storage.h"
#include "vcl.h"
+#include "vcli.h"
+#include "vcli_priv.h"
#include "waiter/waiter.h"
+#include "vsa.h"
/*
* The panic string is constructed in memory, then copied to the
@@ -572,6 +577,99 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
/*--------------------------------------------------------------------*/
+static void __match_proto__(cli_func_t)
+cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv)
+{
+ (void)av;
+ AZ(priv);
+
+#define SZOF(foo) VCLI_Out(cli, \
+ "sizeof(%s) = %zd = 0x%zx\n", #foo, sizeof(foo), sizeof(foo))
+ SZOF(struct ws);
+ SZOF(struct http);
+ SZOF(struct http_conn);
+ SZOF(struct acct_req);
+ SZOF(struct worker);
+ SZOF(struct wrk_accept);
+ SZOF(struct storage);
+ SZOF(struct busyobj);
+ SZOF(struct object);
+ SZOF(struct objcore);
+ SZOF(struct objhead);
+ SZOF(struct sess);
+ SZOF(struct req);
+ SZOF(struct vbc);
+ SZOF(struct VSC_C_main);
+ SZOF(struct lock);
+ SZOF(struct dstat);
+ VCLI_Out(cli, "sizeof(struct suckaddr) = %d = 0x%x\n",
+ vsa_suckaddr_len, vsa_suckaddr_len);
+#if 0
+#define OFOF(foo, bar) { foo __foo; VCLI_Out(cli, \
+ "%-30s = 0x%4zx @ 0x%4zx\n", \
+ #foo "." #bar, sizeof(__foo.bar), offsetof(foo, bar)); }
+#if 0
+ OFOF(struct objhead, magic);
+ OFOF(struct objhead, refcnt);
+ OFOF(struct objhead, mtx);
+ OFOF(struct objhead, objcs);
+ OFOF(struct objhead, digest);
+ OFOF(struct objhead, waitinglist);
+ OFOF(struct objhead, _u);
+#endif
+#if 0
+ OFOF(struct http, magic);
+ OFOF(struct http, logtag);
+ OFOF(struct http, ws);
+ OFOF(struct http, hd);
+ OFOF(struct http, hdf);
+ OFOF(struct http, shd);
+ OFOF(struct http, nhd);
+ OFOF(struct http, status);
+ OFOF(struct http, protover);
+ OFOF(struct http, conds);
+#endif
+#if 0
+ OFOF(struct storage, magic);
+ OFOF(struct storage, fd);
+ OFOF(struct storage, where);
+ OFOF(struct storage, list);
+ OFOF(struct storage, stevedore);
+ OFOF(struct storage, priv);
+ OFOF(struct storage, ptr);
+ OFOF(struct storage, len);
+ OFOF(struct storage, space);
+#endif
+#undef OFOF
+#endif
+}
+
+/*--------------------------------------------------------------------*/
+
+static void __match_proto__(cli_func_t)
+ccf_panic(struct cli *cli, const char * const *av, void *priv)
+{
+
+ (void)cli;
+ (void)av;
+ AZ(priv);
+ AZ(strcmp("", "You asked for it"));
+}
+
+/*--------------------------------------------------------------------*/
+
+static struct cli_proto debug_cmds[] = {
+ { "debug.sizeof", "debug.sizeof",
+ "\tDump sizeof various data structures.",
+ 0, 0, "d", cli_debug_sizeof },
+ { "debug.panic.worker", "debug.panic.worker",
+ "\tPanic the worker process.",
+ 0, 0, "d", ccf_panic },
+ { NULL }
+};
+
+/*--------------------------------------------------------------------*/
+
void
PAN_Init(void)
{
@@ -582,4 +680,5 @@ PAN_Init(void)
AN(heritage.panic_str_len);
AN(VSB_new(pan_vsp, heritage.panic_str, heritage.panic_str_len,
VSB_FIXEDLEN));
+ CLI_AddFuncs(debug_cmds);
}
More information about the varnish-commit
mailing list