LWP doesn't honour timeouts for HTTPS, so use an alarm instead
This should close Bugilla Bug #1609
http://old.linux-foundation.org/developer_bugzilla/show_bug.cgi?id=1609
As discovered by Tuomo Soini
Signed-off-by: Simon Horman <[EMAIL PROTECTED]>
Index: heartbeat/ldirectord/ldirectord.in
===================================================================
--- heartbeat.orig/ldirectord/ldirectord.in 2007-07-04 14:51:19.000000000
+0900
+++ heartbeat/ldirectord/ldirectord.in 2007-07-04 14:51:24.000000000 +0900
@@ -2162,17 +2162,31 @@ sub check_http
. "virtualhost=\"$virtualhost\"");
my $ua = new LWP::UserAgent();
- $ua->timeout($$v{negotiatetimeout});
my $h = new HTTP::Headers("Host" => $virtualhost);
my $req = new HTTP::Request("$$v{httpmethod}", "$$r{url}", $h);
my $res;
- {
+
+ # LWP does not seem to honour timeouts set using $ua->timeout()
+ # for HTTPS. So use an alarm instead. This also has the advantage
+ # of being cumulative timeout, rather than a per send/receive
+ # timeout.
+ eval {
# LWP makes ungaurded calls to eval
# which throw a fatal exception if they fail
# Needless to say, this is completely stupid.
+ # Resetting of $SIG{'__DIE__'} is also
+ # needed now that alarm() is used.
local $SIG{'__DIE__'} = "DEFAULT";
+ local $SIG{'ALRM'} = sub { die "Timeout Alarm" };
+ &ld_debug(4, "Timeout is $$v{negotiatetimeout}");
+ &ld_debug(2, "Starting Check");
+ alarm $$v{negotiatetimeout};
+
+ &ld_debug(2, "Starting HTTP/HTTPS");
$res = $ua->request($req);
- }
+ &ld_debug(2, "Finished HTTP/HTTPS");
+ alarm 0; # Cancel the alarm
+ };
if ($$v{service} eq "https") {
&ld_debug(2, "SSL-Cipher: " .
--
--
Horms
H: http://www.vergenet.net/~horms/
W: http://www.valinux.co.jp/en/
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/