LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: ldirectord https timeout not working?

To: Horms <horms@xxxxxxxxxxxx>
Subject: Re: ldirectord https timeout not working?
Cc: lvs-users@xxxxxxxxxxxxxxxxxxxxxx
From: Scott Jones <scott@xxxxxxxxxxxxxxxxxx>
Date: 31 May 2002 08:13:53 -0700
Awesome!  Thank you for taking a look at that...  In the meantime, I had
done the following to use wget (which is even uglier!).

Cheers,

Scott

sub check_https
{
        my ($v, $r) = @_;
        $uri = $$v{request};
        my $result = `wget -q -t 1 -T $$v{negotiatetimeout} -O - 
$$r{server}:$$r{port}/$uri`;
        if ( !($recstr =~ /.+/) || $result =~ /$recstr/ ) {
                service_set($v, $r, "up");
                return 1;
        }
        service_set($v, $r, "down");
        return 0;
}

On Thu, 2002-05-30 at 20:28, Horms wrote:
> Hi Scott,
> 
> thanks for bringing this problem to my attention. There does
> indeed seem to be a limitation in the Net::SSLeay perl library
> in that it doesn't seem to have a facility to set a timeout.
> 
> I have a work around for this, using a call to alarm() (Yuck!)
> and the resulting code should respect the negotiatetimeout
> that has been set. The resulting check_https is below. I
> have committed this change to CVS and recommend that you get
> that version to make sure that you have the latest bug fixes.
> 
> Information on accessing the linux-ha tree, where ldirectord
> lives, via CVS or the web can be found on www.linux-ha.org.
> 
> -- 
> Horms
> 
> 
> sub check_https
> {
>       my ($v, $r) = @_;
>       require Net::SSLeay;
>       $Net::SSLeay::trace = 0;
>       my $uri = $$v{request};
>       my ($page, $result, %headers);
>       eval {
>               local $SIG{__WARN__};
>               local $SIG{'__DIE__'} = "DEFAULT";
>               local $SIG{'ALRM'} = sub { die "Timeout Alarm" };
>               alarm $$v{negotiatetimeout};
>               ($page, $result, %headers)  = 
> &Net::SSLeay::get_https($$r{server}, $$r{port}, $uri);
>               my $recstr = $$r{receive};
>               warn("Testing: $$r{server}, $$r{port}, $uri");
>               if($result =~ /error/i ||
>                               ($recstr =~ /.+/ && !($page =~ /$recstr/))) {
>                       die("$result");
>               }
>       };
>       alarm 0; # Cancel the alarm
> 
>       if ($@) {
>               service_set($v, $r, "down");
>               return 0;
>       }
>       service_set($v, $r, "up");
>       return 1;
> }



<Prev in Thread] Current Thread [Next in Thread>