summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhanglei <zhanglei@gmail.com>2009-08-03 23:33:36 +0000
committerzhanglei <zhanglei@gmail.com>2009-08-03 23:33:36 +0000
commitf681734fc3c14f7fa2ac0517b538afc2c2fc5713 (patch)
tree3d232ed7f1b2a7236c5df0a92907e09efdcd4624
parent85280b05a1ee94ecbc4086105339e553a4dd79ef (diff)
downloaddistcc-git-f681734fc3c14f7fa2ac0517b538afc2c2fc5713.tar.gz
Make max_discrepancies_before_demotion configurable via DISTCC_MAX_DISCREPANCY environment variable.
-rw-r--r--man/distcc.14
-rw-r--r--man/pump.15
-rwxr-xr-xpump.in12
-rw-r--r--src/compile.c32
4 files changed, 46 insertions, 7 deletions
diff --git a/man/distcc.1 b/man/distcc.1
index 283f868..e3528cb 100644
--- a/man/distcc.1
+++ b/man/distcc.1
@@ -800,6 +800,10 @@ locally. Built-in heuristics prevent some such discrepancy email from being sen
the problem is that a local file changed between the failing remote compilation
and the succeeding local compilation.
.TP
+.B "DISTCC_MAX_DISCREPANCY"
+The maximum number of remote compilation failures allowed in pump mode before
+distcc switches to plain distcc mode. By default set to 1.
+.TP
.B "DCC_EMAILLOG_WHOM_TO_BLAME"
The email address for discrepancy email; the default is "distcc-pump-errors".
.TP
diff --git a/man/pump.1 b/man/pump.1
index 11da428..5177c2d 100644
--- a/man/pump.1
+++ b/man/pump.1
@@ -127,6 +127,11 @@ pump script in the installation executes), then
Python executables and distcc itself will be retrieved
from the parent directory of the location.
.TP
+.B "DISTCC_MAX_DISCREPANCY"
+see the
+.BR distcc(1)
+man page.
+.TP
.B DISTCC_POTENTIAL_HOSTS
The distcc servers that will be queried by lsdistcc
in order to produce a value for DISTCC_HOSTS.
diff --git a/pump.in b/pump.in
index 9597096..acad32c 100755
--- a/pump.in
+++ b/pump.in
@@ -139,9 +139,19 @@ GetScriptDir() {
# Constants used by this process.
-# TODO(klarlund) This value must be the same as that in src/compile.c. See
+# The default value must be the same as that in src/compile.c. See
# comment there.
max_discrepancies_before_demotion=1
+if [ -n "$DISTCC_MAX_DISCREPANCY" ] ; then
+ if [ "$DISTCC_MAX_DISCREPANCY" -le 0 ] ; then
+ echo "$0:" \
+ "Bad DISTCC_MAX_DISCREPANCY value: \"$DISTCC_MAX_DISCREPANCY\"." \
+ "Needs to be 1 or greater." \
+ 1>&2
+ exit 1
+ fi
+ max_discrepancies_before_demotion="$DISTCC_MAX_DISCREPANCY"
+fi
# Variables inherited from the environment of the caller.
diff --git a/src/compile.c b/src/compile.c
index 2fc60b7..edd605d 100644
--- a/src/compile.c
+++ b/src/compile.c
@@ -68,13 +68,33 @@
*/
int dcc_scan_includes = 0;
-/* TODO(klarlund)Warning: this constant should have the same value as in the
- * pump.in script! Make it configurable and user changeable.*/
-static const int max_discrepancies_before_demotion = 1;
-
static const char *const include_server_port_suffix = "/socket";
static const char *const discrepancy_suffix = "/discrepancy_counter";
+static int dcc_get_max_discrepancies_before_demotion(void)
+{
+ /* Warning: the default setting here should have the same value as in the
+ * pump.in script! */
+ static const int default_setting = 1;
+ static int current_setting = 0;
+
+ if (current_setting > 0)
+ return current_setting;
+
+ const char *user_setting = getenv("DISTCC_MAX_DISCREPANCY");
+ if (user_setting) {
+ int parsed_user_setting = atoi(user_setting);
+ if (parsed_user_setting <= 0) {
+ rs_log_error("Bad DISTCC_MAX_DISCREPANCY value: %s", user_setting);
+ exit(EXIT_BAD_ARGUMENTS);
+ }
+ current_setting = parsed_user_setting;
+ } else {
+ current_setting = default_setting;
+ }
+ return current_setting;
+}
+
/**
* Return in @param filename the name of the file we use as unary counter of
* discrepancies (a compilation failing on the server, but succeeding
@@ -158,7 +178,7 @@ static int dcc_note_discrepancy(const char *discrepancy_filename)
assured that exactly one process will take the 'if' branch when
max_discrepancies_before_demotion failures is reached. */
if (ftell(discrepancy_file) ==
- (long int)max_discrepancies_before_demotion) {
+ (long int)dcc_get_max_discrepancies_before_demotion()) {
rs_log_warning("now using plain distcc, possibly due to "
"inconsistent file system changes during build");
}
@@ -182,7 +202,7 @@ static void dcc_perhaps_adjust_cpp_where_and_protover(
/* Check whether there has been too much trouble running distcc-pump during
this build. */
if (dcc_read_number_discrepancies(discrepancy_filename) >=
- max_discrepancies_before_demotion) {
+ dcc_get_max_discrepancies_before_demotion()) {
/* Give up on using distcc-pump */
host->cpp_where = DCC_CPP_ON_CLIENT;
dcc_get_protover_from_features(host->compr,