Subject: | Timeout doesn't work with bgsend/bgread |
The following code hangs forever if the lookup supplied times out. I've been testing this with "testing10.com" which is a domain I came across accidently that is timing out.
========================================================================
#!/usr/bin/perl
use strict;
use warnings;
use IO::Select;
use Net::DNS;
my $res = Net::DNS::Resolver->new;
$res->udp_timeout(5);
my $sock = $res->bgsend($ARGV[0],'NS');
my $sel = IO::Select->new( $sock );
my( $readable, undef, $exception ) = IO::Select->select( $sel, undef, $sel );
========================================================================
To deal with this I have had to add a timeout to the select call, and a section of code which keeps track of DNS queries that have been submitted but not responded to.
In the above code, after 5 seconds, I would have expected either the $readable or $exception arrayrefs to contain the socked which has timed out.
If this is a bug, please fix, if not, please consider it a feature request. Thanks.