r3532 - branches/2.0/varnish-cache/bin/varnishd
    tfheen at projects.linpro.no 
    tfheen at projects.linpro.no
       
    Mon Jan 19 14:29:00 CET 2009
    
    
  
Author: tfheen
Date: 2009-01-19 14:28:59 +0100 (Mon, 19 Jan 2009)
New Revision: 3532
Modified:
   branches/2.0/varnish-cache/bin/varnishd/cache_center.c
Log:
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.
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_center.c	2009-01-19 13:24:13 UTC (rev 3531)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_center.c	2009-01-19 13:28:59 UTC (rev 3532)
@@ -1064,9 +1064,23 @@
 	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 }
 };
 
    
    
More information about the varnish-commit
mailing list