Skip Menu |
 

This queue is for tickets about the ParaDNS CPAN distribution.

Report information
The Basics
Id: 55728
Status: new
Priority: 0/
Queue: ParaDNS

People
Owner: Nobody in particular
Requestors: guillaume [...] filion.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 2.0
Fixed in: (no value)



Subject: nameserver is only set in constructor
Description: Different "nameservers" options for different queries are not honored because the nameserver option is set in the Resolver.pm constructor. Steps to reproduce: ParaDNS->new( callback => sub { print "Got result: $_[0]\n" }, host => 'google.com', nameserver => '8.8.8.8' ); ParaDNS->new( callback => sub { print "Got result: $_[0]\n" }, host => 'google.com', nameserver => '8.8.4.4' ); Actual result: The script will send two queries to 8.8.8.8. Expected result: The script will send one query 8.8.8.8 and one to 8.8.4.4. Fix: I was able to fix this for my application by creating a new resolver for each request, but that's pretty suboptimal... ParaDNS.pm 58c58 < $RESOLVER{$$} ||= ParaDNS::Resolver->new($servers); --- Show quoted text
> $RESOLVER{$$} = ParaDNS::Resolver->new($servers);
A real solution(tm) might be harder to come up with. I tried putting the nameserver setup outside of the Resolver.pm constructor but that didn't work out because of the way it asynchronously works (I guess)...
From: guillaume [...] filion.org
Download (untitled) / with headers
text/plain 117b
A good night sleep gave me the inspiration for an elegant solution (IMHO)! I'm not sure about the XS stuff though...
Subject: paradns-nameservers.patch
--- ParaDNS-2.0/lib/ParaDNS.pm 2010-02-26 14:06:24.000000000 -0500 +++ ParaDNS-2.0-gfk2/lib/ParaDNS.pm 2010-03-20 09:34:13.000000000 -0400 @@ -28,7 +28,7 @@ use constant XS_AVAILABLE => eval { require ParaDNS::XS; }; use constant NO_DNS => ($ENV{NODNS} || 0); -my %RESOLVER; +my $RESOLVER; use constant TRACE_LEVEL => ($ENV{PARADNS_DEBUG} || 0); use constant INTERNAL_CACHE => !($ENV{PARADNS_NO_CACHE} || 0); @@ -49,13 +49,13 @@ $cache_cleanup ||= Danga::Socket->AddTimer(CACHE_CLEAN_INTERVAL, \&_cache_cleanup); } if (XS_AVAILABLE) { - return 1 if $RESOLVER{$$}; + return 1 if $RESOLVER->{$$}; ParaDNS::XS::setup(); - $RESOLVER{$$} = 1; + $RESOLVER->{$$} = 1; } else { my $servers = shift; - $RESOLVER{$$} ||= ParaDNS::Resolver->new($servers); + $RESOLVER->{$$}->{$servers} ||= ParaDNS::Resolver->new($servers); } }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.