Subject: | Timeouts After WHOIS Socket Connection Not Handled |
Date: | Fri, 11 May 2007 10:25:15 -0700 |
To: | bug-Net-Whois-Raw [...] rt.cpan.org |
From: | Greg Wittel <gwittel [...] proofpoint.com> |
Module Version: 1.21
Perl Version: 5.8.8
OS: Linux robotron 2.6.9-42.ELsmp #1 SMP Sat Aug 12 09:39:11 CDT 2006 i686
i686 i386 GNU/Linux
In the function whois_query(), you apply a timeout via alarm() during the
socket connection phase, but its not applied during the socket read phase:
337 my $prev_alarm=0;
338 eval {
339 local $SIG{'ALRM'} = sub { die "Connection timeout to $srv" };
340 $prev_alarm = alarm $TIMEOUT if $TIMEOUT;
341 if (scalar(@SRC_IPS)) {
342 my $src_ip = $SRC_IPS[0];
343 push @SRC_IPS, shift @SRC_IPS; # rotate ips
344 $sock = new IO::Socket::INET(PeerAddr => "$srv:43",
LocalAddr => $src_ip) || die "$s rv: $!";
345 } else {
346 $sock = new IO::Socket::INET("$srv:43") || die "$srv: $!";
347 }
348 };
349 alarm $prev_alarm;
At line 349, $SIG{ALRM} is now undefined, so even if $prev_alarm gets set
with a non-zero time, there is no handler for the signal.
Fix is to either re-create $SIG{ALRM} before calling alarm($prev_alarm) or
move the handler out of the eval.
----
-Greg