From: Jarkko Hietaniemi Date: Mon, 8 Sep 2003 15:47:14 +0000 (+0000) Subject: Slightly more intelligent paranoia. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6cfd5ea7086c16bedf34dfa0b3283bb8e558c285;p=p5sagit%2Fp5-mst-13.2.git Slightly more intelligent paranoia. p4raw-id: //depot/perl@21093 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 5e60211..3ed1161 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -4526,6 +4526,12 @@ which means that Perl 5 will try to call the subroutine when the assignment is executed, which is probably not what you want. (If it IS what you want, put an & in front.) +=item Your random numbers are not that random + +(F) When trying to initialise the random seed for hashes, Perl could +not get any randomness out of your system. This usually indicates +Something Very Wrong. + =back =cut diff --git a/util.c b/util.c index 39122be..c750a2e 100644 --- a/util.c +++ b/util.c @@ -4422,8 +4422,11 @@ Perl_get_hash_seed(pTHX) myseed += (UV)(Drand01() * (NV)((1 << ((UVSIZE * 8 - RANDBITS))) - 1)); #endif /* RANDBITS < (UVSIZE * 8) */ - while (myseed == 0) /* Superparanoia. */ - myseed += (UV)(Drand01() * (NV)UV_MAX); + if (myseed == 0) { /* Superparanoia. */ + myseed = (UV)(Drand01() * (NV)UV_MAX); /* One more chance. */ + if (myseed == 0) + Perl_croak(aTHX_ "Your random numbers are not that random"); + } } PL_hash_seed_set = TRUE;