Subject: | Current versions of LWP do eval - so $@ does not reach the ParanoidAgent. |
Here is a stack trace of the die in lib/LWPx/Protocol/http_paranoid.pm
line 394:
LWPx::Protocol::http_paranoid::SocketMethods::sysread(\'LWPx::Protocol::http_paranoid::Socket=GLOB(0x870fc80)\',
\'\', 4096) called at /usr/local/share/perl/5.8.8/Net/HTTP/Methods.pm
line 236
Net::HTTP::Methods::my_read(\'LWPx::Protocol::http_paranoid::Socket=GLOB(0x870fc80)\',
\'\', 4096) called at /usr/local/share/perl/5.8.8/Net/HTTP/Methods.pm
line 541
Net::HTTP::Methods::read_entity_body(\'LWPx::Protocol::http_paranoid::Socket=GLOB(0x870fc80)\',
\'\', 4096) called at lib/LWPx/Protocol/http_paranoid.pm line 352
LWPx::Protocol::http_paranoid::__ANON__ called at
/usr/local/share/perl/5.8.8/LWP/Protocol.pm line 157
eval {...} called at /usr/local/share/perl/5.8.8/LWP/Protocol.pm line 99
LWP::Protocol::collect(\'LWPx::Protocol::http_paranoid=HASH(0x86bd904)\', \'undef\',
\'HTTP::Response=HASH(0x8929ed0)\', \'CODE(0x892a32c)\') called at
lib/LWPx/Protocol/http_paranoid.pm line 358
LWPx::Protocol::http_paranoid::request(\'LWPx::Protocol::http_paranoid=HASH(0x86bd904)\',
\'HTTP::Request=HASH(0x867f4e8)\', \'undef\', \'undef\', \'undef\', 2)
called at lib/LWPx/ParanoidAgent.pm line 314
eval {...} called at lib/LWPx/ParanoidAgent.pm line 313
LWPx::ParanoidAgent::send_request(\'LWPx::ParanoidAgent=HASH(0x86465b8)\',
\'HTTP::Request=HASH(0x867f4e8)\', \'undef\', \'undef\') called at
/usr/local/share/perl/5.8.8/LWP/UserAgent.pm line 255
LWP::UserAgent::simple_request(\'LWPx::ParanoidAgent=HASH(0x86465b8)\',
\'HTTP::Request=HASH(0x867f4e8)\', \'undef\', \'undef\') called at
/usr/local/share/perl/5.8.8/LWP/UserAgent.pm line 263
LWP::UserAgent::request(\'LWPx::ParanoidAgent=HASH(0x86465b8)\',
\'HTTP::Request=HASH(0x867f4e8)\', \'undef\', \'undef\', \'undef\')
called at lib/LWPx/ParanoidAgent.pm line 219
As you can see there is an "eval {...} called at
/usr/local/share/perl/5.8.8/LWP/Protocol.pm line 99" so the eval in line
313 of ParanoidAgent does not get the right $@.
The result is that in timeouts the client dies - but no error is
reported, and the test "5 second tarpit (tolerance 2)" fails.
Here is a patch:
zby@zby:~/progs/pa$ svn diff
Index: lib/LWPx/ParanoidAgent.pm
===================================================================
--- lib/LWPx/ParanoidAgent.pm (revision 18)
+++ lib/LWPx/ParanoidAgent.pm (working copy)
@@ -314,11 +314,12 @@
$response = $protocol->request($request, $proxy,
$arg, $size, $timeout);
};
- if ($@) {
- $@ =~ s/ at .* line \d+.*//s; # remove file/line number
+ my $error = $@ || $response->header( 'x-died' );
+ if ($error) {
+ $error =~ s/ at .* line \d+.*//s; # remove file/line number
$response = _new_response($request,
&HTTP::Status::RC_INTERNAL_SERVER_ERROR,
- $@);
+ $error);
}
}
else {
zby@zby:~/progs/pa$
This is agains the version from
http://code.sixapart.com/svn/LWPx-ParanoidAgent/trunk
Cheers,
Zbigniew