LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: mysql not parsed in Ldirectord config.

To: "LinuxVirtualServer.org users mailing list." <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: mysql not parsed in Ldirectord config.
From: "Graham David Purcocks M.A.(Oxon.)" <grahamp@xxxxxxxxxxxxx>
Date: Fri, 20 May 2005 09:54:00 +0100
I have supplied Horm with patches for both these problems. Net::FTP
doesn't like memory files anyway.

I also added Postgres support. My patches are similar but you don't need
IO::String. Simple temp file is sufficient.

If you'd like a copy of mine let me know.

Graham


On Thu, 2005-05-19 at 23:01, Patrick Walsh wrote:
> On Thu, 2005-05-12 at 15:33 +0900, Horms wrote:
> > > Here is a patch, I changed from a memory file to a virtual temporary
> > > file. This is after appying both the mysql patch and the Postgres patch.
> > > 
> > > -----------------------------------------------------
> > > --- /usr/sbin/ldirectord        2005-04-28 17:13:40.000000000 +0000
> > > +++ ldirectord  2005-05-11 14:51:57.000000000 +0000
> > > @@ -2079,7 +2079,8 @@
> > > 
> > >         &ld_debug(2, "Checking ftp server=$$r{server} port=$port");
> > > 
> > > -       open(MEMORY,'>', \$memory);
> > > +       # Open temporary file
> > > +       open(TMP,'>', undef);
> 
>       FYI: this code relies on perl 5.8.  Those of us stuck using perl 5.6
> can't do this.  The open command in perl 5.6 only accepts file
> references, so files that look like "SCALAR(0x122345)" start appearing
> in funny places and check_ftp() never succeeds.
> 
>       This can be worked around by using the IO::String module.  I'm
> attaching a patch [resend; patch now pasted at bottom of this msg]
> that detects the perl version and if it is less than
> 5.8 tries to use IO::String.  I hope you will include this patch so that
> we don't have to maintain our own ldirectord.  (The patch is based on
> current CVS).
> 
>       Also, in case the ultramonkey project or some others want to include
> RPMs for IO::String, I've created a spec file that will build the latest
> IO::String module.  E-mail me off-list if you'd like a copy.
> 
> Patch:
> 
> --- ldirectord.orig   Thu May 19 15:19:54 2005
> +++ ldirectord        Thu May 19 15:21:53 2005
> @@ -2061,11 +2061,24 @@
>       my ($v, $r) = @_;
>       my $ftp;
>       my $memory;
> +     my $results;
>       my $port=(defined $$v{checkport}?$$v{checkport}:$$r{port});
>  
>       &ld_debug(2, "Checking ftp server=$$r{server} port=$port");
>       
> -     open(TMP,'+>', undef);
> +     if ( $] < 5.008 ) {
> +             eval {
> +                     require IO::String;
> +                     $memory = IO::String->new();
> +             };
> +             if ( $@ ) {
> +                     &ld_debug(2, "FTP check requires IO::String on this 
> version of perl.");
> +                     return 0;
> +             }
> +     } else {
> +             open(TMP,'+>', undef);
> +             $memory = *TMP;
> +     }
>  
>       unless ($ftp = Net::FTP->new("$$r{server}:$port", 
>                       Timeout=>$$v{negotiatetimeout})) {
> @@ -2076,15 +2089,20 @@
>       $ftp->cwd("/");
>       $ftp->binary();
>       $ftp->pasv();
> -     $ftp->get("$$r{request}", *TMP);
> +     $ftp->get("$$r{request}", $memory);
>       $ftp->quit();
>  
> -     seek TMP, 0, 0;
> -     local $/;
> -     $memory = <TMP>;
> -     close TMP;
> +     if ( $] < 5.008 ) {
> +             $results = $memory->string_ref;
> +             $results = $$results;
> +             $memory = undef;
> +     } else {
> +             seek TMP, 0, 0;
> +             local $/;
> +             $results = <TMP>;
> +             close TMP;
> +     }
>  
> -     if ($memory =~ /$$r{receive}/) {
> +     if ($results =~ /$$r{receive}/) {
>               service_set($v, $r, "up");
>               return 1;
>       }
-- 

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