Commit c0e6650d authored by Tollef Fog Heen's avatar Tollef Fog Heen

Merge r3366:

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: http://www.varnish-cache.org/svn/branches/2.0@3532 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 7dadad3f
......@@ -1064,9 +1064,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 }
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment