Send Linux-ha-cvs mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."


Today's Topics:

   1. Linux-HA CVS: ldirectord by horms from 
      ([email protected])
   2. Linux-HA CVS: ldirectord by horms from 
      ([email protected])
   3. Linux-HA CVS: ldirectord by horms from 
      ([email protected])
   4. Linux-HA CVS: ldirectord by horms from 
      ([email protected])


----------------------------------------------------------------------

Message: 1
Date: Mon, 30 Jan 2006 17:30:26 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: ldirectord by horms from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : horms
Host    : 
Project : linux-ha
Module  : ldirectord

Dir     : linux-ha/ldirectord


Modified Files:
      Tag: STABLE_1_2
        ldirectord 


Log Message:
the the -> the
Sync with 1.129, HEAD
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord,v
retrieving revision 1.77.2.37
retrieving revision 1.77.2.38
diff -u -3 -r1.77.2.37 -r1.77.2.38
--- ldirectord  1 Dec 2005 00:39:40 -0000       1.77.2.37
+++ ldirectord  31 Jan 2006 00:30:26 -0000      1.77.2.38
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-my($VERSION)=(qw$Id: ldirectord,v 1.77.2.37 2005/12/01 00:39:40 horms Exp 
$)[2];
+my($VERSION)=(qw$Id: ldirectord,v 1.77.2.38 2006/01/31 00:30:26 horms Exp 
$)[2];
 
 ######################################################################
 # ldirectord                 http://www.vergenet.net/linux/ldirectord/
@@ -76,7 +76,7 @@
 B<start> the daemon for the specified configuration.
 
 B<stop> the daemon for the specified configuration. This is the same as sending
-a TERM signal the the running daemon.
+a TERM signal the running daemon.
 
 B<restart> the daemon for the specified configuration. The same as stopping 
and starting.
 
@@ -225,7 +225,7 @@
 B<checktype = >I<negotiate>|I<connect>|I<N>|I<ping>|I<off>|I<on>
 
 Type of check to perform. Negotiate sends a request and matches a receive
-string. Connect only attemts to make a TCP/IP connection, thus the the
+string. Connect only attemts to make a TCP/IP connection, thus the
 request and receive strings may be omitted.  If checktype is a number then
 negotiate and connect is combined so that after each N connect attempts one
 negotiate attempt is performed. This is useful to check often if a service




------------------------------

Message: 2
Date: Mon, 30 Jan 2006 17:38:03 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: ldirectord by horms from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : horms
Host    : 
Project : linux-ha
Module  : ldirectord

Dir     : linux-ha/ldirectord


Modified Files:
        ldirectord 


Log Message:
Remove uncaught alarm in eval which is a race condition in the connect and sip 
checks. Bug #1022. Thanks to Keith Bucher.
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -3 -r1.129 -r1.130
--- ldirectord  15 Jan 2006 16:25:19 -0000      1.129
+++ ldirectord  31 Jan 2006 00:38:02 -0000      1.130
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-my($VERSION)=(qw$Id: ldirectord,v 1.129 2006/01/15 16:25:19 xunsun Exp $)[2];
+my($VERSION)=(qw$Id: ldirectord,v 1.130 2006/01/31 00:38:02 horms Exp $)[2];
 
 ######################################################################
 # ldirectord                 http://www.vergenet.net/linux/ldirectord/
@@ -2040,7 +2040,8 @@
                if ($sock) {
                        close($sock);
                } else {
-                       die(); #socket attempt failed immediately (not timeout)
+                       alarm 0; # Cancel the alarm
+                       die("Socket Connect Failed");
                }
                &ld_debug(3, "Connected to $1 (port $port)");
                alarm 0; # Cancel the alarm
@@ -2076,7 +2077,8 @@
                my $sock = &ld_open_socket($$r{server}, $sip_d_port, 
                                        $$v{protocol});
                unless ($sock) {
-                       die(); #socket attempt failed immediately (not timeout)
+                       alarm 0;
+                       die("Socket Connect Failed");
                }
 
                my $sip_sockaddr = getsockname($sock);
@@ -3038,6 +3040,7 @@
        my $request = "";
        my $receive = "";
        my $checkport = "";
+       my $virtualhost = "";
        my $check;
        my $real;
 
@@ -3067,10 +3070,14 @@
                $checkport = $v->{"checkport"};
        }
 
+       if(defined($v->{"virtualhost"})) {
+               $virtualhost = $v->{"virtualhost"};
+       }
 
         $real    = $check . ":" . $v->{"protocol"} . ":" 
                 . $r->{"server"} . ":" . $r->{"port"} . ":" 
-                . $checkport . ":" . $r->{"weight"} . ":"
+                . $virtualhost . ":" . $checkport . ":" 
+                . $r->{"weight"} . ":"
                 . quotemeta($request) . ":" . quotemeta($receive);
 }
 




------------------------------

Message: 3
Date: Mon, 30 Jan 2006 17:40:03 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: ldirectord by horms from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : horms
Host    : 
Project : linux-ha
Module  : ldirectord

Dir     : linux-ha/ldirectord


Modified Files:
      Tag: STABLE_1_2
        ldirectord 


Log Message:
Remove uncaught alarm in eval which is a race condition in the connect and sip 
checks. Bug #1022. Thanks to Keith Bucher. Sync with HEAD (1.130)
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord,v
retrieving revision 1.77.2.38
retrieving revision 1.77.2.39
diff -u -3 -r1.77.2.38 -r1.77.2.39
--- ldirectord  31 Jan 2006 00:30:26 -0000      1.77.2.38
+++ ldirectord  31 Jan 2006 00:40:03 -0000      1.77.2.39
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-my($VERSION)=(qw$Id: ldirectord,v 1.77.2.38 2006/01/31 00:30:26 horms Exp 
$)[2];
+my($VERSION)=(qw$Id: ldirectord,v 1.77.2.39 2006/01/31 00:40:03 horms Exp 
$)[2];
 
 ######################################################################
 # ldirectord                 http://www.vergenet.net/linux/ldirectord/
@@ -2006,7 +2006,8 @@
                if ($sock) {
                        close($sock);
                } else {
-                       die(); #socket attempt failed immediately (not timeout)
+                       alarm 0; # Cancel the alarm
+                       die("Socket Connect Failed");
                }
                &ld_debug(3, "Connected to $1 (port $port)");
                alarm 0; # Cancel the alarm
@@ -2042,7 +2043,8 @@
                my $sock = &ld_open_socket($$r{server}, $sip_d_port, 
                                        $$v{protocol});
                unless ($sock) {
-                       die(); #socket attempt failed immediately (not timeout)
+                       alarm 0;
+                       die("Socket Connect Failed");
                }
 
                my $sip_sockaddr = getsockname($sock);




------------------------------

Message: 4
Date: Mon, 30 Jan 2006 17:46:16 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: ldirectord by horms from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : horms
Host    : 
Project : linux-ha
Module  : ldirectord

Dir     : linux-ha/ldirectord


Modified Files:
      Tag: STABLE_1_2
        ldirectord 


Log Message:
Actually sync with head 1.130 (previous commits were missing some older changes)
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord,v
retrieving revision 1.77.2.39
retrieving revision 1.77.2.40
diff -u -3 -r1.77.2.39 -r1.77.2.40
--- ldirectord  31 Jan 2006 00:40:03 -0000      1.77.2.39
+++ ldirectord  31 Jan 2006 00:46:16 -0000      1.77.2.40
@@ -1,12 +1,14 @@
 #!/usr/bin/perl
-my($VERSION)=(qw$Id: ldirectord,v 1.77.2.39 2006/01/31 00:40:03 horms Exp 
$)[2];
+my($VERSION)=(qw$Id: ldirectord,v 1.77.2.40 2006/01/31 00:46:16 horms Exp 
$)[2];
 
 ######################################################################
 # ldirectord                 http://www.vergenet.net/linux/ldirectord/
 # Linux Director Daemon - run "perldoc ldirectord" for details
 #
-# (C) 1999-2003 Jacob Rief <[EMAIL PROTECTED]>
-# (C) 1999-2003 Horms <[EMAIL PROTECTED]>
+# 1999-2005 (C) Jacob Rief <[EMAIL PROTECTED]>,
+#               Horms <[EMAIL PROTECTED]> and others
+#
+# License:      GNU General Public License (GPL)
 #
 # Note: * The original author of this software was Jacob Rief circa 1999
 #       * It was maintained by Jacob Rief and Horms 
@@ -39,9 +41,10 @@
 
 =head1 SYNOPSIS
 
-B<ldirectord> [B<-d>] [B<-h>] I<configuration> 
+B<ldirectord> [B<-d|--debug>] [--] [I<configfile>] 
 B<start>|B<stop>|B<restart>|B<reload>|B<status>
 
+B<ldirectord> [B<-h|-?|--help|-v|--version>]
 
 =head1 DESCRIPTION
 
@@ -69,14 +72,16 @@
 This is the name for the configuration as specified in the file
 B</etc/ha.d/conf/>I<configuration>
 
-B<-d> Don't start as daemon. Useful for debugging.
+B<-d|--debug> Don't start as daemon and log verbosly. 
+
+B<-h|--help> Print user manual and exit.
 
-B<-h> Help. Print user manual of ldirectord.
+B<-v|--version> Print version and exit.
 
 B<start> the daemon for the specified configuration.
 
 B<stop> the daemon for the specified configuration. This is the same as sending
-a TERM signal the running daemon.
+a TERM signal to the running daemon.
 
 B<restart> the daemon for the specified configuration. The same as stopping 
and starting.
 
@@ -404,7 +409,10 @@
 $CHECKINTERVAL    = 10;
 $CHECKTIMEOUT     = 5;
 $CONNECTTIMEOUT   = 0;
-$LDIRECTORD       = "/usr/sbin/ldirectord"; # path onto myself
+$LDIRECTORD       = ld_find_cmd("ldirectord", 1);
+if (! defined $LDIRECTORD) {
+       $LDIRECTORD = "/usr/sbin/ldirectord";
+}
 $LDIRLOG          = "/var/log/ldirectord.log";
 $LD_TERM_CALLED   = 0;
 $NEGOTIATETIMEOUT = 0;
@@ -413,7 +421,8 @@
 
 $CRLF = "\x0d\x0a";
 
-use Getopt::Std;
+use Getopt::Long;
+use Pod::Usage;
 #use English;
 #use Time::HiRes qw( gettimeofday tv_interval );
 use Socket;
@@ -423,10 +432,33 @@
 
 # command line options
 my @OLD_ARGV = @ARGV;
-getopts("dh");
+my $opt_d = '';
+my $opt_h = '';
+my $opt_v = '';
+Getopt::Long::Configure ("bundling", "no_auto_abbrev", "require_order");
+GetOptions("debug|d" => \$opt_d, 
+          "help|h|?" => \$opt_h,
+          "version|v" => \$opt_v) or usage();
 
-$DEBUG = 3 if (defined $opt_d);
+# main code
+if ($opt_h) {
+       exec_wrapper("/usr/bin/perldoc -U $LDIRECTORD");
+       &ld_exit(127, "Exec failed");
+}
+if ($opt_v) {
+       print("ldirectord  version $VERSION\n" .
+             "1999-2005 Jacob Rief, Horms and others\n" .
+             "<http://www.vergenet.net/linux/ldirectord/>\n".
+             "\n" .
+             "ldirectord comes with ABSOLUTELY NO WARRANTY.\n" .
+             "This is free software, and you are welcome to redistribute it\n".
+             "under certain conditions. " .
+                     "See the GNU General Public Licence for details.\n");
+
+       &ld_exit(0, "");
+}
 
+$DEBUG = 3 if ($opt_d);
 if ($DEBUG>0 and -f "./ipvsadm") {
        $IPVSADM="./ipvsadm";
 } else {
@@ -439,27 +471,23 @@
        }
 }
 
-# main code
-if ($opt_h) {
-       &system_wrapper("/usr/bin/perldoc -U $LDIRECTORD");
-} else {
-       # There is a memory leak in perl's socket code when
-       # the default IO layer is used. So use "perlio" unless
-       # something else has been explicitly set.
-       # http://archive.develooper.com/[email protected]/msg85468.html
-       unless(defined($ENV{'PERLIO'})) {
-               $ENV{'PERLIO'} = "perlio";
-               exec_wrapper($0, @OLD_ARGV);
-       }
-
-       $initializing = 1;
-       ld_init();
-       ld_setup();
-       ld_start();
-       ld_cmd_children("start", %LD_INSTANCE);
-       $initializing = 0;
-       ld_main();
-}
+# There is a memory leak in perl's socket code when
+# the default IO layer is used. So use "perlio" unless
+# something else has been explicitly set.
+# http://archive.develooper.com/[email protected]/msg85468.html
+unless(defined($ENV{'PERLIO'})) {
+       $ENV{'PERLIO'} = "perlio";
+       exec_wrapper($0, @OLD_ARGV);
+}
+
+$initializing = 1;
+ld_init();
+ld_setup();
+ld_start();
+ld_cmd_children("start", %LD_INSTANCE);
+$initializing = 0;
+ld_main();
+
 &ld_rm_file("$RUNPID.$CFGNAME.pid");
 &ld_exit(0, "Reached end of \"main\"");
 
@@ -533,6 +561,14 @@
        read_config();
        undef @OLDVIRTUAL;
 
+       {
+               my $log_str = "Invoking ldirectord invoked as: $0 ";
+               for my $i (@ARGV) {
+                       $log_str .= $i . " ";
+               }
+               ld_log($log_str);
+       }
+
        my $oldpid;
        my $filepid;
        if (open(FILE, "<$RUNPID.$CFGNAME.pid")) {
@@ -612,10 +648,7 @@
 
 sub usage
 {
-       init_error("Usage ldirectord [-d] [configfile] " .
-               "\{start|stop|restart|try-restart|reload|force-reload|" .
-               "status\}\n" .
-               "Type ldirectord -h for more information");
+       pod2usage(-input => $LDIRECTORD, -exitval => -1);
 }
 
 sub init_error
@@ -1553,7 +1586,7 @@
                for my $k (keys %$or) {
                        &system_wrapper("$IPVSADM -d " . $nv->{proto} .
                                        &get_virtual($nv) . " -r $k");
-                       &ld_log("Removed real server: $k (" . 
+                       &ld_log("Removed real server (start): $k (" . 
                                        #scalar(%{$nv->{real_status}}) .
                                        " x " .  &get_virtual($nv) . ")\n");
                        delete($$or{$k});
@@ -1579,7 +1612,8 @@
                # service still exists, remove it
                &system_wrapper("$IPVSADM -D " . $nv->{proto} . " " . 
                                &get_virtual($nv));
-               &ld_log("Removed virtual server: " . &get_virtual($nv) . "\n");
+               &ld_log("Removed virtual server (start): " . 
+                               &get_virtual($nv) . "\n");
        }
 }
 
@@ -1603,14 +1637,14 @@
                        if (defined $$r{virtual_status}) {
                                &system_wrapper("$IPVSADM -d $$v{proto} " . 
&get_virtual($v) . " -r $$r{server}:$$r{port}");
                                _status_down($v, $r);
-                               &ld_log("Removed real server: " .
+                               &ld_log("Removed real server (stop): " .
                                        "$$r{server}:$$r{port} (" .
                                        #scalar(%{$v->{real_status}}) . 
-                                       " x " . &get_virtual($v) );
+                                       " x " . &get_virtual($v) . ")" );
                        }
                }
                &system_wrapper("$IPVSADM -D $$v{proto} " .  &get_virtual($v));
-               &ld_log("Removed virtual server: " .  &get_virtual($v));
+               &ld_log("Removed virtual server (stop): " .  &get_virtual($v));
        }
 }
 
@@ -2522,7 +2556,7 @@
 }
 
 # Set the status of a server as down
-# Should onlu be called from _service_down or _ld_stop
+# Should only be called from _service_down or ld_stop
 
 sub _status_down
 {
@@ -2776,7 +2810,7 @@
                print "[$now] $message\n";
        } elsif ( $LDIRLOG =~ /^\/(.*)/ ) {
                unless (open(LOGFILE, ">>$LDIRLOG")
-                               and print LOGFILE "[$now|$CFGNAME] $message\n"
+                               and print LOGFILE "[$now|$CFGNAME|$$] 
$message\n"
                                and close(LOGFILE)) {
                        print STDERR "$message\n";
                        return 1;
@@ -3006,6 +3040,7 @@
        my $request = "";
        my $receive = "";
        my $checkport = "";
+       my $virtualhost = "";
        my $check;
        my $real;
 
@@ -3035,10 +3070,14 @@
                $checkport = $v->{"checkport"};
        }
 
+       if(defined($v->{"virtualhost"})) {
+               $virtualhost = $v->{"virtualhost"};
+       }
 
         $real    = $check . ":" . $v->{"protocol"} . ":" 
                 . $r->{"server"} . ":" . $r->{"port"} . ":" 
-                . $checkport . ":" . $r->{"weight"} . ":"
+                . $virtualhost . ":" . $checkport . ":" 
+                . $r->{"weight"} . ":"
                 . quotemeta($request) . ":" . quotemeta($receive);
 }
 
@@ -3322,3 +3361,46 @@
        }
        return($ip);
 }
+
+
+# ld_find_cmd_path
+# Find executable in path
+# pre: cmd: command to find
+#      path: ':' delimited paths to check
+#      relative: if set, allow cmd to be a relative path, 
+#                which is checked first
+# return: path to command
+#         undef if not found
+sub ld_find_cmd_path
+{
+       my ($cmd, $path, $relative) = (@_);
+
+       if (defined $relative  and $relative and -f "$cmd" ) {
+               return $cmd;
+       }
+       if ($cmd =~ /^\// and -x "$cmd" ) {
+               return $cmd;
+       }
+       if ($cmd =~ /\//) {
+               return undef;
+       }
+
+       for my $p (split /:/, $path) {
+               if ( -x "$p/$cmd" ) {
+                       return "$p/$cmd";
+               }
+       }
+       return undef;
+}
+
+# ld_find_cmd_path
+# Find executable in $ENV{'PATH'}
+# pre: cmd: command to find
+#      relative: if set, allow cmd to be a relative path, 
+#                which is checked first
+# return: path to command
+#         undef if not found
+sub ld_find_cmd
+{
+       return ld_find_cmd_path($_[0], $ENV{'PATH'}, $_[1]);
+}




------------------------------

_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 26, Issue 66
********************************************

Reply via email to