Sumit Bose <[EMAIL PROTECTED]> writes: > Hi, > > we have encountered a strange problem in UserAgent.pm. Our script terminates > with the message: > > Can't call method "request" on an undefined value at > /usr/lib/perl5/site_perl/5.8.0/LWP/UserAgent.pm line 362. > > Maybe, although eval is used $response is still undef? The following patch > might help here, but we are not sure, because the problem only arises under > special high load conditions.
You would have to make the test '!defined($response)' instead of 'undef($reponse)' to make it work, but I will not apply this fix to my source as it only hides the real problem. But I can't see how this can happen. It must mean that $protocol->request() sometimes return undef and it is not allowed to do that. Could you perhaps add some log information that print out what request was tried when this happen? There might be some pattern to it. > --- /usr/lib/perl5/site_perl/5.8.0/LWP/UserAgent.pm 2001-12-11 > 22:11:29.000000000 +0100 > +++ /tmp/UserAgent.pm 2003-10-07 16:20:55.000000000 +0200 > @@ -347,7 +347,7 @@ > $response = $protocol->request($request, $proxy, > $arg, $size, $timeout); > }; > - if ($@) { > + if ($@ || undef($response) ) { > $@ =~ s/ at .* line \d+.*//s; # remove file/line number > $response = > HTTP::Response->new(&HTTP::Status::RC_INTERNAL_SERVER_ERROR, > > > Do you have an idea what might happen here? Is it possible that eval fails > and $@ is undef or can HTTP::Response->new fail and return undef? We use > version 5.65 and I haven't seen any changes in this code-block in 5.69. I don't know any change that is relevant. This is another guy with the same problem <http://ftp.ics.uci.edu/pub/websoft/libwww-perl/archive/2001h1/0071.html>. This one seems to be HTTPS related. Are yours? Regards, Gisle