Nobody should be using rand as a cryptographically secure pseudo-random
number generator anyway.

Each worker could, for example, instantiate its own instance of a
Bytes::Random::Secure object, each of which will start with its own seed
taken from a strong source that is provided by Crypt::Random::Seed.
On Mar 22, 2014 4:35 PM, "Alexander Karelas" <[email protected]> wrote:

> Bernhard's suggestion doesn't solve the problem. What you need to do is
> write this in your startup routine:
>
>
>
>
> *use Mojo::IOLoop;Mojo::IOLoop->next_tick(sub{    srand;});*
>
> This trick documented here:
> https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Built-in-web-server
> near the end of the chapter
>
> On Sunday, March 18, 2012 8:00:48 PM UTC+2, Bernhard Graf wrote:
>>
>> > I have an issue with rand().
>> >
>> > In all forked processes rand() gives me the same set of random
>> > symbols. May be call srand() after forking? How to do it correctly?
>>
>> You rand() before Hypnotoad forks, so all processes share the same seed.
>>
>> Move your (s)rand outside startup() into a has/helper declaration.
>>
>> HTH
>>
>> Bernhard
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to