develooper Front page | perl.perl5.porters | Postings from September 2003

Timeout bug in LWP due to IO::Socket::INET ?

From:
Christophe Chisogne
Date:
September 10, 2003 01:12
Subject:
Timeout bug in LWP due to IO::Socket::INET ?
Message ID:
3F5EDCE2.6000807@publicityweb.com

With LPW::Useragent->timeout(5), I got timeouts of 20secs or more
(not the 5secs requested), at least with not responding webservers.
See below for a simple test code. (No, I'm not behind a 56k modem ;-)

Tested on LWP 5.69, Perl 5.8.0, Linux 2.4.18
and    on LWP 5.43, Perl 5.005_03, Linux 2.2.16

LWP passes the timeout arg to IO::Socket::INET.
For Perl 5.8, the whole timeout things is commented out
in IO::Socket:INET ! For Perl 5.43, it's not the case,
but the pblm seems to be there (longer timeouts, but
busiest server)

Is this a bug in IO::Socket::INET timeout code ? What's going on ?
Is this related to a change in the interrupt model of Perl ?

Could someone point me in the right direction ?
(I _really_ need a true timeout, to avoid verrry long
  running time)

Thanks in advance

Searching the libwww-perl archives I found this:

 > From: Gisle Aas
 > Subject: Re: $ua->timeout info
 > Date: Wed, 06 Feb 2002 10:42:15 -0800
 > (...) timeout setting (...)
 > 1) It is passed in as Timeout argument to IO::Socket::INET's
 >       constructor.  IO::Socket::INET currently only use this to
 >       fail the connect(2) call if it takes too long.  The DNS
 >       lookup of the hostname is done by IO::Socket::INET before
 >       it even considers the timeout.

Does this really means there's no mean to avoid DNS timeouts with LWP?

time test.pl:
real    0m21.901s
user    0m0.110s
sys     0m0.000s

------------------------------------
test.pl :
------------------------------------
#!/usr/bin/perl -w

use HTTP::Request;
use LWP::UserAgent;

$url= 'http://www.busca.net'; # or undefined dns domain
$ua= new LWP::UserAgent;
$ua->timeout(5);
$request= new HTTP::Request('GET', $url);
$response= $ua->request($request);
# code 500 after a (too long) time : 20secs, or even minits!
print "... Received code " . $response->code . "\n";
------------------------------------


-- 
Christophe




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About