diff options
author | Kamal Mostafa <kamal@whence.com> | 2012-04-04 20:28:47 +0000 |
---|---|---|
committer | Kamal Mostafa <kamal@whence.com> | 2012-04-04 20:28:47 +0000 |
commit | 3c90113fc3411e4baa18aab9d32b2dea36a15ae7 (patch) | |
tree | 31d0086c17f15a10d1676a9a7414c37d7a396874 | |
parent | 231bb60fc46a7facb554c4fba0c8625158f66cde (diff) | |
download | distcc-git-3c90113fc3411e4baa18aab9d32b2dea36a15ae7.tar.gz |
Fix for distcc issue 103 <http://code.google.com/p/distcc/issues/detail?id=103>:
hardcoded 60 second backoff period should be tunable
Makes the backoff behavior tunable via a new env var DISTCC_BACKOFF_PERIOD.
The default backoff remains set for 60 seconds.
-rw-r--r-- | man/distcc.1 | 6 | ||||
-rw-r--r-- | src/backoff.c | 27 |
2 files changed, 31 insertions, 2 deletions
diff --git a/man/distcc.1 b/man/distcc.1 index e335d05..9ab9afb 100644 --- a/man/distcc.1 +++ b/man/distcc.1 @@ -762,6 +762,12 @@ variable is set to 0 then fallbacks are disabled and those compilations will simply fail. Note that this does not affect jobs which must always be local such as linking. .TP +.B "DISTCC_BACKOFF_PERIOD" +Specifies how long (in seconds) distcc will avoid trying to use a +particular compilation server after that server yields a compile +failure. By default set to 60 seconds. To disable the backoff +behavior altogether, set this to 0. +.TP .B "DISTCC_IO_TIMEOUT" Specifies how long (in seconds) distcc will wait before deciding a distributed job has timed out. If a distributed job is expected to diff --git a/src/backoff.c b/src/backoff.c index abc86ed..b3d656c 100644 --- a/src/backoff.c +++ b/src/backoff.c @@ -50,7 +50,7 @@ #include "hosts.h" -const int dcc_backoff_period = 60; /* seconds */ +static int dcc_backoff_period = 60; /* seconds */ /** @@ -61,12 +61,26 @@ const int dcc_backoff_period = 60; /* seconds */ **/ int dcc_enjoyed_host(const struct dcc_hostdef *host) { + char *bp; + + /* special-case: if DISTCC_BACKOFF_PERIOD==0, don't manage backoff files */ + bp = getenv("DISTCC_BACKOFF_PERIOD"); + if (bp && (atoi(bp) == 0)) + return 0; + return dcc_remove_timefile("backoff", host); } int dcc_disliked_host(const struct dcc_hostdef *host) { - /* i hate you (but only for 60 seconds) */ + char *bp; + + /* special-case: if DISTCC_BACKOFF_PERIOD==0, don't manage backoff files */ + bp = getenv("DISTCC_BACKOFF_PERIOD"); + if (bp && (atoi(bp) == 0)) + return 0; + + /* i hate you (but only for dcc_backoff_period seconds) */ return dcc_mark_timefile("backoff", host); } @@ -94,6 +108,15 @@ static int dcc_check_backoff(struct dcc_hostdef *host) int dcc_remove_disliked(struct dcc_hostdef **hostlist) { struct dcc_hostdef *h; + char *bp; + + bp = getenv("DISTCC_BACKOFF_PERIOD"); + if (bp) + dcc_backoff_period = atoi(bp); + + /* special-case: if DISTCC_BACKOFF_PERIOD==0, don't manage backoff files */ + if (dcc_backoff_period == 0) + return 0; while ((h = *hostlist) != NULL) { if (dcc_check_backoff(h) != 0) { |