On Sat, 15 May 2010 22:03:50 +0200, Anthony Esposito <tony.m.espos...@gmail.com> wrote:

In one of my programs I started to receive database errors for not having a unique id. I generate unique ids for each of the mysql lines that I add to the database. I realized that the perl variable $idNum was keeping the same random string for multiple executions.

I've been there too.
Same problem, with mod perl 2.04.

This is what I have in my startup.pl:

  # Every mp process needs a different random seed, or they will
  # generate the exact same random number sequence every time,
  # resulting in tokens collision
  my $srv = Apache2::ServerUtil->server;
  $srv->push_handlers(PerlChildInitHandler => sub { srand(time ^ $$) } );

--
Cosimo

Reply via email to