Patch 2/4

This forces resetting of unset configuration directives to defaults.

The default values for global configuration directives are set once
early on in the start up.  If a configuration file specifies a global
configuration option and then, at a later time, that option is removed
from the configuration file, the global variable will neither get set
nor reset during the configuration reload.  This results in the old
setting persisting, instead of the expect and documented "default" value
in  the absence of the configuration directive.

This patch puts all the defaults into a function (set_defaults) which
is called once at startup and once at every configuration reload.  All
global configuration defaults should be set in this function when added
or changed.

Thanks,
Sean
# HG changeset patch
# User Sean E. Millichamp <[email protected]>
# Date 1242072917 14400
# Node ID 6081ec3a7a9c6556827b21ce5eb7bcfbec303d80
# Parent  74cca79b94440d95b1b2891e50f05f7f4afd3116
Force resetting of unset configuration directives to defaults.

The default values for global configuration directives are set once
early on in the start up.  If a configuration file specifies a global
configuration option and then, at a later time, that option is removed
from the configuration file, the global variable will neither get set
nor reset during the configuration reload.  This results in the old setting
persisting, instead of the expect and documented "default" value in
the absence of the configuration directive.

This patch puts all the defaults into a function (set_defaults) which
is called once at startup and once at every configuration reload.  All
global configuration defaults should be set in this function when added
or changed.

Signed-Off-By: Sean E. Millichamp <[email protected]>

diff -r 74cca79b9444 -r 6081ec3a7a9c ldirectord/ldirectord.in
--- a/ldirectord/ldirectord.in	Mon May 11 14:44:12 2009 -0400
+++ b/ldirectord/ldirectord.in	Mon May 11 16:15:17 2009 -0400
@@ -663,6 +663,7 @@
 =cut
 
 use strict;
+# Set defaults for configuration variables in the "set_defaults" function
 use vars qw(
 	    $VERSION_STR
 	    $AUTOCHECK
@@ -737,30 +738,17 @@
 # default values
 $DAEMON_TERM      = undef;
 $DAEMON_HUP       = undef;
-$AUTOCHECK        = "no";
-$CHECKINTERVAL    = 10;
-$DEFAULT_CHECKTIMEOUT     = 5;
-$CHECKTIMEOUT     = -1;
-$CHECKCOUNT       = 1;
-$FAILURECOUNT     = 1;
 $LDIRECTORD       = ld_find_cmd("ldirectord", 1);
 if (! defined $LDIRECTORD) {
 	$LDIRECTORD = "@sbindir@/ldirectord";
 }
-$LDIRLOG          = "/var/log/ldirectord.log";
-$NEGOTIATETIMEOUT = -1;
-$DEFAULT_NEGOTIATETIMEOUT = 30;
 $RUNPID           = "/var/run/ldirectord";
-$SUPERVISED       = "no";
-$FORKING          = "no";
-$QUIESCENT        = "no";
-$EMAILALERT	  = "";
-$EMAILALERTFREQ	  = 0;
-$EMAILALERTSTATUS = $DAEMON_STATUS_ALL;
-$CLEANSTOP	  = "yes"; 
 
 $CRLF = "\x0d\x0a";
 
+# Set global configuration default values:
+set_defaults();
+
 use Getopt::Long;
 use Pod::Usage;
 #use English;
@@ -1170,6 +1158,29 @@
 	return $status;
 }
 
+sub set_defaults {
+	$AUTOCHECK        = "no";
+	$CALLBACK         = undef;
+	$CHECKCOUNT       = 1;
+	$CHECKINTERVAL    = 10;
+	$CHECKTIMEOUT     = -1;
+	$CLEANSTOP	  = "yes"; 
+	$DEFAULT_CHECKTIMEOUT     = 5;
+	$DEFAULT_NEGOTIATETIMEOUT = 30;
+	$EMAILALERT	  = "";
+	$EMAILALERTFREQ	  = 0;
+	$EMAILALERTSTATUS = $DAEMON_STATUS_ALL;
+	$FAILURECOUNT     = 1;
+	$FALLBACK         = undef;
+	$FALLBACKCOMMAND  = undef;
+	$FORKING          = "no";
+	$LDIRLOG          = "/var/log/ldirectord.log";
+	$NEGOTIATETIMEOUT = -1;
+	$QUIESCENT        = "no";
+	$SUPERVISED       = "no";
+	$SMTP             = undef;
+}
+
 sub read_config
 {
 	undef @VIRTUAL;
@@ -1177,6 +1188,8 @@
 	undef $CALLBACK;
 	undef %LD_INSTANCE;
 	undef $checksum;
+	# Reset/set global config variables to defaults before parsing the config file.
+	set_defaults();
 	$stattime = 0;
 	my %virtual_seen;
 	open(CFGFILE, "<$CONFIG") or
_______________________________________________
Please read the documentation before posting - it's available at:
http://www.linuxvirtualserver.org/

LinuxVirtualServer.org mailing list - [email protected]
Send requests to [email protected]
or go to http://lists.graemef.net/mailman/listinfo/lvs-users

Reply via email to