Hi,
I need a script to check a bunch of links -- a mix of ftp and http.
The
http works passably, but the ftp has serious problems. The code looks
something like this (I didn't write this, so don't ask me why it does
everything it does):
$ua = new LWP::UserAgent;
$request = new HTTP::Request('HEAD',"http://www.nosite.com");
foreach $URL (@urls)
{
$url = new URI::URL $URL
eval {
<paraindent><param>left,left</param>
# set up the alarm handling routine
$SIG{'ALRM'} = sub {
logerror("TIMEOUT on http");
die "TIMEOUT";
};
alarm 15;
$request->url($url);
$request->header("Accept" => "*/*; mxb=200");
$response = $ua->simple_request($request);
$ret_code = $response->code();
}
</paraindent>}
According to the log files, the script may go through a few URLs
successfully, but eventually just hangs. I run it with & and when
I kill it I get this error:
Caught a SIGTERM at /usr/local/lib/perl5.004/site_perl/Net/Cmd.pm line
218
$ = Net::Cmd::getline('Net::FTP=GLOB(0x534c5c)') called from file
`/usr/local/lib/perl5.004/site_perl/Net/Cmd.pm' line 277
$ = Net::Cmd::response('Net::FTP=GLOB(0x534c5c)') called from file
`/usr/local/lib/perl5.004/site_perl/Net/FTP.pm' line 738
$ = Net::FTP::response('Net::FTP=GLOB(0x534c5c)') called from file
`/usr/local/lib/perl5.004/site_perl/Net/FTP.pm' line 896
$ = Net::FTP::dataconn::close('Net::FTP::I=GLOB(0x53c320)') called from
file `/usr/local/lib/perl5.004/site_perl/LWP/Protocol/ftp.pm' line 159
$ = LWP::Protocol::ftp::request('LWP::Protocol::ftp=HASH(0x4c5374)',
'HTTP::Request=HASH(0xb6814)', '', '', '', 180) called from file
`/usr/local/lib/perl5.004/site_perl/LWP/UserAgent.pm' line 215
$ = eval {...} called from file
`/usr/local/lib/perl5.004/site_perl/LWP/UserAgent.pm' line 214
$ = LWP::UserAgent::simple_request('LWP::UserAgent=HASH(0x4735a0)',
'HTTP::Request=HASH(0xb6814)') called from file `update.reliability.pl'
line 743
$ = eval {...} called from file `update.reliability.pl' line 724
@ =
main::checkURL('ftp://ftp.bitcon.no/.4/simtelnet/win95/sound/agraeq10.zip',1)
called from file `update.reliability.pl' line 566
$ = main::reliabilityCheck(.1) called from file `update.reliability.pl'
line 339
Going through the files listed here, it looks like what happens is the
LWP code makes a request, then tries to close the connection. It sends
the close request then waits for a response, and gets stuck in the wait
loop when the response doesn't come.
An additional problem here is that, even though this is
libwww-perl-5.33,
the alarm timers still aren't working, and the internal socket timeouts
don't seem to either.
Can anybody give me some ideas about what may be happening here?
Thanks
Adam
adamc@cnet.com