From ad065fdb38f06b8154230d97e600602f71aea17a Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 10 Nov 2008 09:29:52 +0000 Subject: [PATCH] Add a debug CLI command to seed random(3). This is a lot less useful than it could have been, as the Open Group only mandates that: Like rand(), random() shall produce by default a sequence of numbers that can be duplicated by calling srandom() with 1 as the seed. But crucially leaves out *which* sequence of numbers. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3366 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_center.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index c05916c8..e3a91509 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -1055,9 +1055,23 @@ cli_debug_xid(struct cli *cli, const char * const *av, void *priv) cli_out(cli, "XID is %u", xids); } +static void +cli_debug_srandom(struct cli *cli, const char * const *av, void *priv) +{ + (void)priv; + unsigned long seed; + + if (av[2] != NULL) + seed = strtoul(av[2], NULL, 0); + srandom(seed); + cli_out(cli, "Random(3) seeded with %lu", seed); +} + static struct cli_proto debug_cmds[] = { { "debug.xid", "debug.xid", "\tExamine or set XID\n", 0, 1, cli_debug_xid }, + { "debug.srandom", "debug.srandom", + "\tSeed the random(3) function\n", 0, 1, cli_debug_srandom }, { NULL } }; -- 2.39.5