I think that the reason that checktimeout and negotiatetimeout
are separate values is to allow them to have different defaults.
However I'm not sure that this is useful and it seems quite confusing.

Futhermore the SIP, DNS and Radius negotiate checks were
using checktimeout instead of negotiatetimeout.

This patch indirectly changes the default negotiatetimeout from 0 to 
5 seconds. 0 might mean infinite for some checks and it might mean the os
default (~1 week for TCP?) in other cases. I'm not sure that 5 seconds
is the best choice, but it seems like a much better choice than 0.

Thanks to Tuomo Soini for leading me to this.

Signed-off-by: Simon Horman <[EMAIL PROTECTED]>

Index: heartbeat/ldirectord/ldirectord.in
===================================================================
--- heartbeat.orig/ldirectord/ldirectord.in     2007-07-03 16:49:11.000000000 
+0900
+++ heartbeat/ldirectord/ldirectord.in  2007-07-03 16:58:55.000000000 +0900
@@ -121,11 +121,10 @@ Default: 5 seconds
 
 B<negotiatetimeout = >I<n>
 
-Timeout in seconds for negotiate checks. 
+Depricated in favour of checktimeout.
 
-If defined in a virtual server section then the global value is overridden.
-
-Default: defined by the operating system
+In order to aid transition of old configurations, if checktimeout is not
+set in the same scope, it will be set to the value of negotiatetimeout.
 
 B<checkinterval = >I<n>
 
@@ -277,10 +276,11 @@ two strings must be quoted. If the reque
 the IP-address and port of the real server is overridden, otherwise the
 IP-address and port of the real server is used.
 
-=head2 More than one of these entries may be inside a virtual section.  The
-checktimeout, negotiatetimeout, checkcount, fallback, emailalert,
-emailalertfreq and quiescent options listed above may also appear inside a
-virtual section, in which case the global setting is overridden.
+=head2
+More than one of these entries may be inside a virtual section.  The
+checktimeout, checkcount, fallback, emailalert, emailalertfreq and
+quiescent options listed above may also appear inside a virtual section, in
+which case the global setting is overridden.
 
 B<checktype = >B<negotiate>|B<connect>|I<N>|B<ping>|B<off>|B<on>
 
@@ -519,6 +519,7 @@ use vars qw(
            $NEGOTIATETIMEOUT
            $RUNPID
            $CHECKTIMEOUT
+           $DEFAULT_CHECKTIMEOUT
            $CHECKCOUNT
            $QUIESCENT
            $EMAILALERT
@@ -571,14 +572,15 @@ $DAEMON_TERM      = undef;
 $DAEMON_HUP       = undef;
 $AUTOCHECK        = "no";
 $CHECKINTERVAL    = 10;
-$CHECKTIMEOUT     = 5;
+$CHECKTIMEOUT     = -1;
+$DEFAULT_CHECKTIMEOUT     = 5;
 $CHECKCOUNT       = 1;
 $LDIRECTORD       = ld_find_cmd("ldirectord", 1);
 if (! defined $LDIRECTORD) {
        $LDIRECTORD = "@sbindir@/ldirectord";
 }
 $LDIRLOG          = "/var/log/ldirectord.log";
-$NEGOTIATETIMEOUT = 0;
+$NEGOTIATETIMEOUT = -1;
 $RUNPID           = "/var/run/ldirectord";
 $SUPERVISED       = "no";
 $QUIESCENT        = "yes";
@@ -1067,10 +1069,14 @@ sub read_config
                                        &config_error($line,
                                                "connecttimeout directive " .
                                                "deprecated in favour of " .
-                                               "negotiatetimeout");
+                                               "checktimeout");
                                } elsif ($rcmd =~ 
/^negotiatetimeout\s*=\s*(.*)/){
                                         $1 =~ /(\d+)/ && $1 or 
&config_error($line, "invalid negotiate timeout");
                                         $vsrv{negotiatetimeout} = $1;
+                                       &config_warn($line,
+                                               "negotiatetimeou directive " .
+                                               "deprecated in favour of " .
+                                               "checktimeout");
                                } elsif ($rcmd =~ /^checkcount\s*=\s*(.*)/){
                                         $1 =~ /(\d+)/ && $1 or 
&config_error($line, "invalid check count");
                                         $vsrv{checkcount} = $1;
@@ -1216,11 +1222,15 @@ sub read_config
                        &config_error($line,
                                        "connecttimeout directive " .
                                        "deprecated in favour of " .
-                                       "negotiatetimeout");
+                                       "checktimeout");
                } elsif ($linedata  =~ /^negotiatetimeout\s*=\s*(.*)/) {
                        ($1 =~ /(\d+)/ && $1 && $1>0) or &config_error($line, 
                                        "invalid negotiate timeout value");
                        $NEGOTIATETIMEOUT = $1;
+                       &config_warn($line,
+                                       "negotiatetimeout directive " .
+                                       "deprecated in favour of " .
+                                       "checktimeout");
                } elsif ($linedata  =~ /^checkinterval\s*=\s*(.*)/) {
                        $1 =~ /(\d+)/ && $1 or &config_error($line, 
                                        "invalid check interval value");
@@ -1297,8 +1307,7 @@ sub read_config
                                &config_error($line, 
                                                "timeout directive " .
                                                "deprecated in favour of " .
-                                               "checktimeout and " .
-                                               "negotiatetimeout");
+                                               "checktimeout");
                        }
                        &config_error($line, "Unknown command $linedata ");
                }
@@ -1743,14 +1752,17 @@ sub ld_setup
                                $$r{num_connects} = -1;
                        }
                }
-               if ($$v{checktimeout} < 0) {
+               if ($$v{checktimeout} < 0 and $$v{negotiatetimeout} >= 0) {
+                       $$v{negotiatetimeout} = $$v{negotiatetimeout};
+               }
+               if ($$v{checktimeout} < 0 and $CHECKTIMEOUT >= 0) {
                        $$v{checktimeout} = $CHECKTIMEOUT;
                }
-               if ($$v{negotiatetimeout} < 0) {
+               if ($$v{checktimeout} < 0 and $NEGOTIATETIMEOUT >= 0) {
                        $$v{negotiatetimeout} = $NEGOTIATETIMEOUT;
                }
-               if ($$v{negotiatetimeout} < 0) {
-                       $$v{negotiatetimeout} = $$v{checktimeout};
+               if ($$v{checktimeout}) {
+                       $$v{negotiatetimeout} = $DEFAULT_CHECKTIMEOUT;
                }
                if ($$v{checkcount} < 0) {
                        $$v{checkcount} = $CHECKCOUNT;
@@ -2117,7 +2129,7 @@ sub check_http
                . "virtualhost=\"$virtualhost\"");
        
        my $ua = new LWP::UserAgent();
-       $ua->timeout($$v{negotiatetimeout});
+       $ua->timeout($$v{checktimeout});
        my $h = new  HTTP::Headers("Host" => $virtualhost);
        my $req = new HTTP::Request("$$v{httpmethod}", "$$r{url}", $h);
        my $res;
@@ -2162,7 +2174,7 @@ sub check_smtp
        &ld_debug(2, "Checking smtp: server=$$r{server} port=$port");
 
        my $smtp = new Net::SMTP($$r{server}, Port => $port,
-                       Timeout => $$v{negotiatetimeout});
+                       Timeout => $$v{checktimeout});
        if ($smtp) {
                $smtp->quit;
                service_set($v, $r, "up");
@@ -2187,7 +2199,7 @@ sub check_pop
                                         USESSL => 0,
                                         PORT => $port,
                                         DEBUG => 0,
-                                        TIMEOUT => $$v{negotiatetimeout});
+                                        TIMEOUT => $$v{checktimeout});
 
         if (!$pop) {
                 service_set($v, $r, "down");
@@ -2222,7 +2234,7 @@ sub check_pops
                                         USESSL => 1,
                                         PORT => $port,
                                         DEBUG => 0,
-                                        TIMEOUT => $$v{negotiatetimeout});
+                                        TIMEOUT => $$v{checktimeout});
         if (!$pops) {
                 service_set($v, $r, "down");
                 return 1;
@@ -2253,7 +2265,7 @@ sub check_imap
         
         my $imap = Net::IMAP::Simple->new($$r{server},
                                         port => $port,
-                                        timeout => $$v{negotiatetimeout});
+                                        timeout => $$v{checktimeout});
         
         if (!$imap) {
                 service_set($v, $r, "down");
@@ -2284,7 +2296,7 @@ sub check_imaps
 
         my $imaps = Net::IMAP::Simple::SSL->new($$r{server},
                                         port => $port,
-                                        timeout => $$v{negotiatetimeout});
+                                        timeout => $$v{checktimeout});
         if (!$imaps) {
                 service_set($v, $r, "down");
                 return 1;
@@ -2314,7 +2326,7 @@ sub check_ldap
        
        my $recstr = $$r{receive};
        my $ldap = Net::LDAP->new("$$r{server}", port => $port,
-                                       timeout => $$v{negotiatetimeout});
+                                       timeout => $$v{checktimeout});
        if(!$ldap) {
                service_set($v, $r, "down");
                &ld_debug(4, "Connection failed");
@@ -2376,13 +2388,13 @@ sub check_nntp
        
         unless ($sock = IO::Socket::INET->new(PeerAddr => $$r{server},
                 PeerPort => $port, Proto => 'tcp',
-                TimeOut => $$v{negotiatetimeout})) {
+                TimeOut => $$v{checktimeout})) {
                 service_set($v, $r, "down");
                 return 1;
         }
         $s = IO::Select->new();
         $s->add($sock);
-        if (scalar($s->can_read($$v{negotiatetimeout})) == 0) {
+        if (scalar($s->can_read($$v{checktimeout})) == 0) {
                 service_set($v, $r, "down");
         } else {
                 sysread($sock, $buf, 64);
@@ -2643,7 +2655,7 @@ sub check_ftp
        open(TMP,'+>', undef);
 
        unless ($ftp = Net::FTP->new("$$r{server}:$port", 
-                       Timeout=>$$v{negotiatetimeout})) {
+                       Timeout=>$$v{checktimeout})) {
                service_set($v, $r, "down");
                return 0;
        }

-- 

-- 
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/

Reply via email to