in reply to Re^2: Windows: AnyEvent -> HTTP -> DNS - > Blocking for minutes
in thread Windows: AnyEvent -> HTTP -> DNS - > Blocking for minutes
foreach my $ns ( grep {defined} @_ ) { if ( _ipv4($ns) || _ipv6($ns) ) { push @ip, $ns; } else { my $defres = ref($self)->new( debug => $self->{debug} ); $defres->{persistent} = $self->{persistent}; my $names = {}; my $packet = $defres->send( $ns, 'A' );
That would happen if the nameserver list passed to ->nameservers(@list) contained a string that wasn't an IP address. It seems really odd to me that name servers would ever be specified as names that needed resolved before they could be used to resolve names... maybe you should debug that first to see what the input is?
Try this: (example of monkey-patching)
use Net::DNS::Resolver::Base; my $orig= \&Net::DNS::Resolver::Base::nameservers; local *Net::DNS::Resolver::Base::nameservers= sub { my ($self, @servers)= @_; print "Current nameservers value: " .join(", ", @{$self->{nameservers}//[]}) ."\n"; print "Assigning nameservers: ".join(", ", @servers)."\n" if @servers > 1; $orig->(@_); }; # and then the rest of your program
I don't have a windows system to test on at the moment (well, not one where I can disable the network adapters and still use it) but that will at least show you what is getting assigned there. On my system, it reveals that the default resovlers are "127.0.0.1" and "::1" before the first call to ->nameservers, so yes that would hang if there was not a nameserver listening on localhost and something tried to assign "foo.example.com" as a nameserver.
Meanwhile, I realized that you can override the default timeouts like this:
That effect comes from the AUTOLOAD method on ::Base which generates accessors on demand:use Net::DNS::Resolver; Net::DNS::Resolver->tcp_timeout(1); Net::DNS::Resolver->udp_timeout(1); # remainder of your program
so any time you call an accessor on the package itself, it pulls up the _default resolver and sets the attribute on it instead. Those attributes get used as the defaults for any new resolvers created.sub AUTOLOAD { ## Default method my ($self) = @_; my $name = $AUTOLOAD; $name =~ s/.*://; croak qq[unknown method "$name"] unless $public_attr{$name}; no strict 'refs'; ## no critic ProhibitNoStrict *{$AUTOLOAD} = sub { my $self = shift; $self = $self->_defaults unless ref($self); $self->{$name} = shift || 0 if scalar @_; return $self->{$name}; }; goto &{$AUTOLOAD}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Windows: AnyEvent -> HTTP -> DNS - > Blocking for minutes
by hippo (Archbishop) on Oct 20, 2022 at 08:43 UTC | |
|
Re^4: Windows: AnyEvent -> HTTP -> DNS - > Blocking for minutes
by sectokia (Friar) on Oct 20, 2022 at 04:26 UTC | |
by NERDVANA (Priest) on Oct 20, 2022 at 23:12 UTC | |
by sectokia (Friar) on Oct 21, 2022 at 01:13 UTC |