[smokeping-users] non-uniqe DNS IDs with SmokePing and AnotherDNS
tobi at oetiker.ch
Wed Oct 24 21:08:23 CEST 2012
Today Niko Tyni wrote:
> On Wed, Oct 24, 2012 at 07:07:18PM +0200, Gert Doering wrote:
> > Specifically, every DNS probe SmokePing sends carries the very same
> > Query ID - which it shouldn't do from a DNS PoV, but even from staring
> > at the code involved, this should not happen (I have traces from various
> > versions of SmokePing and perl on FreeBSD and Linux that show this, so
> > I claim it's not my local installation that is borked).
> I think I see the problem. The main SmokePing process forks the probe
> subprocesses, which first call srand() in Smokeping::make_kid() to
> initialize the random number generator. The AnotherDNS probe then
> starts one subprocess for each ping, but all of those inherit the state
> of the RNG.
> Does the attached (untested) patch fix it for you?
> % perl -le 'srand; fork; print "pid $$ => " . rand()'
> pid 5039 => 0.712492274426953
> pid 5040 => 0.712492274426953
> % perl -le 'fork; srand; print "pid $$ => " . rand()'
> pid 5250 => 0.967728406264545
> pid 5251 => 0.62419137808411
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 ...
so maybe it would suffice to NOT call srand in Smokeping.pm ...
in any event, I have merged your patch for now ...
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900
More information about the smokeping-users