[smokeping-users] non-uniqe DNS IDs with SmokePing and AnotherDNS

Niko Tyni ntyni+smokeping-users at mappi.helsinki.fi
Wed Oct 24 21:29:21 CEST 2012


On Wed, Oct 24, 2012 at 09:08:23PM +0200, Tobias Oetiker wrote:

> great ... I was experimenting with the fork call too, but I ignored
> the srand call ... interestingly enough, things work fine if you do
> 
> % perl -le 'fork; print "pid $$ => " . rand()'
> 
> as if perl was doing an automatic srand on fork or someting ...

Yeah, rand() is documented to call srand() on the first time
unless srand() has already been called.

> so maybe it would suffice to NOT call srand in Smokeping.pm ...

Removing all the srand() calls would probably work if we didn't call rand()
before forking either. But we currently do AFAICS, at least with

    if ($offset eq 'random'){
          $offset = int(rand($step));

% perl -le 'rand; fork; print "pid $$ => " . rand()'
pid 25161 => 0.437039271786006
pid 25162 => 0.437039271786006

Also, I see lib/SNMP_util.pm calls srand() on startup :)

So it seems safest to me to just call srand always after forking.

> in any event, I have merged your patch for now ...

Great, thanks :)
-- 
Niko



More information about the smokeping-users mailing list