summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.travis.yml7
-rw-r--r--INSTALL2
-rw-r--r--Makefile.in8
-rw-r--r--NEWS10
-rw-r--r--configure.ac59
-rw-r--r--doc/web/benchmark.html2
-rw-r--r--doc/web/faq.html16
-rw-r--r--doc/web/man/distcc_1.html2
-rw-r--r--doc/web/man/distccd_1.html2
-rw-r--r--doc/web/man/distccmon_text_1.html2
-rw-r--r--doc/web/man/include_server_1.html2
-rw-r--r--docker/base/Dockerfile16
-rw-r--r--docker/compilers/Dockerfile.clang-3.83
-rw-r--r--docker/compilers/Dockerfile.gcc-4.89
-rw-r--r--docker/compilers/Dockerfile.gcc-59
-rw-r--r--include_server/c_extensions/distcc_pump_c_extensions_module.c4
-rwxr-xr-xinclude_server/cache_basics.py4
-rwxr-xr-xinclude_server/include_analyzer.py2
-rwxr-xr-xinclude_server/include_server.py4
-rwxr-xr-xinclude_server/macro_eval.py8
-rwxr-xr-xinclude_server/mirror_path_test.py2
-rwxr-xr-xinclude_server/parse_command.py1
-rwxr-xr-xinclude_server/setup.py2
-rw-r--r--include_server/test_data/distcc/src/distcc.h4
-rw-r--r--include_server/test_data/distcc/src/trace.h2
-rw-r--r--man/distccd.19
-rw-r--r--man/distccmon-text.12
-rw-r--r--packaging/RedHat/conf/clients.allow2
-rwxr-xr-xpackaging/googlecode_upload.py2
-rw-r--r--popt/popt.h4
-rw-r--r--popt/poptconfig.c16
-rw-r--r--popt/popthelp.c7
-rw-r--r--popt/poptparse.c15
-rw-r--r--src/arg.c2
-rw-r--r--src/argutil.c15
-rw-r--r--src/auth_distcc.c2
-rw-r--r--src/auth_distccd.c2
-rw-r--r--src/backoff.c33
-rw-r--r--src/clirpc.c3
-rw-r--r--src/compile.c44
-rw-r--r--src/daemon.c6
-rw-r--r--src/distcc.h2
-rw-r--r--src/dopt.c15
-rw-r--r--src/dopt.h4
-rw-r--r--src/hosts.c6
-rw-r--r--src/io.c4
-rw-r--r--src/loadfile.c2
-rw-r--r--src/mon-gnome.c120
-rw-r--r--src/prefork.c28
-rw-r--r--src/renderer.c72
-rw-r--r--src/renderer.h4
-rw-r--r--src/rpc.c3
-rw-r--r--src/serve.c33
-rw-r--r--src/setuid.c9
-rw-r--r--src/snprintf.c2
-rw-r--r--src/strip.c3
-rw-r--r--src/tempfile.c1
-rw-r--r--src/util.c6
-rw-r--r--src/util.h3
-rwxr-xr-xtest/testdistcc.py19
-rwxr-xr-xupdate-distcc-symlinks.py119
62 files changed, 449 insertions, 353 deletions
diff --git a/.gitignore b/.gitignore
index 1e5f1e7..e2c2371 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
*.out
*.err
# binaries
+/*.exe
distcc
distccd
distccmon-text
diff --git a/.travis.yml b/.travis.yml
index 6c5c7ae..279ff62 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,10 +17,6 @@ addons:
- clang
- libavahi-client-dev
-before_install:
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade python; fi
-
script:
- ./autogen.sh
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./configure; fi
@@ -36,3 +32,6 @@ matrix:
- os: linux
compiler: clang
dist: trusty
+ - os: osx
+ osx_image: xcode11.3
+ compiler: clang
diff --git a/INSTALL b/INSTALL
index 4205137..d3f404c 100644
--- a/INSTALL
+++ b/INSTALL
@@ -14,7 +14,7 @@ QUICK SUMMARY
0. Install prerequisites. For example, on Debian or Ubuntu, you could use
- sudo apt-get install gcc make python3 python3-dev libiberty-dev
+ sudo apt-get install gcc make python3 python3-dev libiberty-dev autoconf
1. Build and install
diff --git a/Makefile.in b/Makefile.in
index b9ce974..f240ca6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -59,7 +59,7 @@ include_server_builddir = $(builddir)/_include_server
# These must be done from here, not from autoconf, because they can
# contain variable expansions written in Make syntax. Ew.
-DIR_DEFS = -DLIBDIR="\"${libdir}\"" -DSYSCONFDIR="\"${sysconfdir}\"" -DICONDIR="\"${icondir}\""
+DIR_DEFS = -DLIBDIR="\"${prefix}/lib\"" -DSYSCONFDIR="\"${sysconfdir}\"" -DICONDIR="\"${icondir}\""
# arguments to pkgconfig
GNOME_PACKAGES = @GNOME_PACKAGES@
@@ -515,7 +515,9 @@ lsdistcc@EXEEXT@: $(lsdistcc_obj)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(lsdistcc_obj) $(LIBS)
update-distcc-symlinks: $(update_distcc_symlinks_PY)
- cp $< $@
+ sed -e "s;\@prefix\@;${prefix};g" $< > $@.tmp
+ chmod +x $@.tmp
+ mv $@.tmp $@
h_exten@EXEEXT@: $(h_exten_obj)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(h_exten_obj) $(LIBS)
@@ -1196,7 +1198,7 @@ uninstall-include-server:
uninstall-man:
for p in $(man1_MEN); do \
file="$(DESTDIR)$(man1dir)/`basename $$p`"; \
- if [ -e "$$file" ]; then rm -fv "$$file"; fi \
+ if [ -e "$$file" ]; then rm -fv "$$file"; fi; \
if [ -e "$$file.gz" ]; then rm -fv "$$file.gz"; fi \
done
-[ "`basename $(man1dir)`" = "$(PACKAGE)" ] && rmdir "$(DESTDIR)$(man1dir)"
diff --git a/NEWS b/NEWS
index 77d308d..b78fb8f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,13 @@
+distcc-3.4 "Lax lexer" 2021-4-11
+
+ FEATURES
+
+ * distccmon-gnome ported from gtk2 to gtk3
+
+ * Remove debug lag in spawning new threads. (better multi-core performance)
+
+ * Bug fixes.
+
distcc-3.3 "Charlie the unicorn" 2018-3-3
FEATURES:
diff --git a/configure.ac b/configure.ac
index 0b9f136..007efb8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,11 +10,23 @@ dnl Process this file with autoconf to produce a configure script
# As of 0.6cvs, distcc no longer uses automake, only autoconf.
AC_PREREQ(2.69)
-AC_INIT(distcc, 3.3.3, distcc@lists.samba.org)
+AC_INIT(distcc, 3.4, distcc@lists.samba.org)
AC_CONFIG_HEADERS(src/config.h)
AC_CONFIG_MACRO_DIRS([m4])
+AC_CANONICAL_HOST
+AC_MSG_CHECKING([if the host system type is Linux])
+case "${host_os}" in
+linux*)
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_LINUX, 1, [Define to 1 if the host system type is Linux.])
+ ;;
+*)
+ AC_MSG_RESULT(no)
+ ;;
+esac
+
# FreeBSD installs its version of libpopt into /usr/local/, but does
# not put that on the default library and header path.
# Solaris doesn't even ship libpopt. We used to add that path if
@@ -62,14 +74,13 @@ getpeername(0,0,&len);
dnl Android requires -llog for printf and friends
dnl and will only run position independent executables
AC_MSG_CHECKING([if building on Android])
-AC_TRY_COMPILE([
+AC_TRY_COMPILE([], [
#ifdef __BIONIC__
int ok;
(void)ok;
#else
choke me
#endif],
-[func("a"); func("a", "b"); func("a", "b", "c")],
[AC_MSG_RESULT(yes)
LDFLAGS="$LDFLAGS -llog -pie"],
[AC_MSG_RESULT(no)])
@@ -133,10 +144,10 @@ AC_ARG_ENABLE(Werror,
# we need. It's faster to just do it once during configuration.
if test "x${with_gnome}" = xyes
then
- GNOME_PACKAGES="gtk+-2.0 libgnome-2.0 libgnomeui-2.0 pango"
+ GNOME_PACKAGES="gtk+-3.0 libgnome-3.0 libgnomeui-3.0 pango"
elif test "x${with_gtk}" = xyes
then
- GNOME_PACKAGES="gtk+-2.0"
+ GNOME_PACKAGES="gtk+-3.0"
else
GNOME_PACKAGES=""
fi
@@ -399,12 +410,11 @@ if (mmap (NULL, 0, 0, 0, 0, 0) == MAP_FAILED)
return 0;
#else
#error mmap unavailable
-#endif], ,[
+#endif], AC_MSG_RESULT(yes), [
+ AC_MSG_RESULT(no)
AC_DEFINE([MAP_FAILED], [(void *)-1L],
[Define if MAP_FAILED constant not available])
])
-AC_MSG_RESULT()
-
dnl
dnl Test if the preprocessor understand vararg macros
@@ -433,9 +443,12 @@ fi
AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
#include <stdarg.h>
-void foo(const char *format, ...) {
+static int foo(const char *format, ...) {
va_list ap;
int len;
char buf[5];
@@ -443,13 +456,13 @@ void foo(const char *format, ...) {
va_start(ap, format);
len = vsnprintf(0, 0, format, ap);
va_end(ap);
- if (len != 5) exit(1);
+ if (len != 5) return 1;
- if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
+ if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) return 1;
- exit(0);
+ return 0;
}
-main() { foo("hello"); }
+int main() { return foo("hello"); }
],
rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
@@ -462,9 +475,9 @@ AC_TRY_RUN([
#include <sys/types.h>
#include <sys/socket.h>
-main() {
+int main() {
int fd[2];
- exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
+ return (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1;
}],
rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
@@ -534,6 +547,22 @@ AC_SUBST(CPPFLAGS)
AC_SUBST(POPT_INCLUDES)
AC_SUBST(BUILD_POPT)
AC_SUBST(GNOME_BIN)
+
+
+# Sometimes canonical triples as used by configure differ from GCC ones
+# x86: configure: x86_64-pc-linux-gnu, GCC: x86_64-linux-gnu
+# ALT Linux: configure: ${arch}-alt-linux-gnu, GCC: ${arch}-alt-linux
+# Therefore ask the compiler for its triple
+if test "x${GCC}" = xyes ; then
+ native_compiler_triple=`$CC -dumpmachine`
+fi
+if test "x$native_compiler_triple" = "x"; then
+ native_compiler_triple="$host"
+fi
+AC_MSG_NOTICE([Native compiler triple: $native_compiler_triple])
+
+AC_DEFINE_UNQUOTED(NATIVE_COMPILER_TRIPLE, ["$native_compiler_triple"], [Native compiler triple])
+
AC_DEFINE_UNQUOTED(GNU_HOST, ["$host"], [Your gnu-style host triple])
# The '.stamp-conf' files force creation of the containing directories in the
# build tree.
diff --git a/doc/web/benchmark.html b/doc/web/benchmark.html
index 9f1c7df..1030640 100644
--- a/doc/web/benchmark.html
+++ b/doc/web/benchmark.html
@@ -153,7 +153,7 @@ project's tarball before building.</p>
<li> The parallelism of the various projects' Makefiles affects
the obtained speedup significantly. Makefiles that
run <code>make</code> sequentially in subdirectories benefit less from
- distcc. They will see little addded benefit from distcc's pump mode
+ distcc. They will see little added benefit from distcc's pump mode
because the sequentiality of their execution allows only some,
but not many, compilations to be issued near
simultaneously. <br><br></li>
diff --git a/doc/web/faq.html b/doc/web/faq.html
index 045f93b..2cce499 100644
--- a/doc/web/faq.html
+++ b/doc/web/faq.html
@@ -207,7 +207,7 @@ This could in principle be changed.
<p>
In some situations, such as a lab of centrally managed machines,
this is quite practical. However, many people have a less
- homogenous environment: perhaps some machines run a different OS
+ homogeneous environment: perhaps some machines run a different OS
release, or developers are allowed to upgrade libraries on their own
machines, or perhaps you just don't want to run NFS.
@@ -293,10 +293,10 @@ something not in root's path, then it should be fine.
<p>
<blockquote>
-i noticed that when you start a make proccess, the remote distccd recieves
-10-15 connections from my host (which is good) and those proccesses die after
+i noticed that when you start a make process, the remote distccd receives
+10-15 connections from my host (which is good) and those processes die after
a while. this is a long compilation (kdelibs) and after the initial
-proccesses die, i cannot see any new one's coming in. is this normal ?
+processes die, i cannot see any new one's coming in. is this normal ?
it seems as if after a while (2-3 minuets) distcc stops working and only my
local gcc is still compiling.
</blockquote>
@@ -325,7 +325,7 @@ local gcc is still compiling.
<p>
<blockquote>
another machine i want to add to this "cluster" is my firewall. its not a
-very powerfull one, but it can help speed things up a little more ;)
+very powerful one, but it can help speed things up a little more ;)
are there any knows security issues with distcc ? how stupid will it be to run
it on a server that acts as a firewall ?
</blockquote>
@@ -634,7 +634,7 @@ after installing distcc into a masquerade directory.
<h3>How to use an SSH TCP port other than 22?</h3>
<p>
<blockquote>
-I want to use two machines over ssh. One machine has a differnt port than
+I want to use two machines over ssh. One machine has a different port than
22. But I can't set a port in the host specifications for ssh.
</blockquote>
<p>
@@ -953,7 +953,7 @@ over the network, and there is no way to pararellize this.
distcc.
<h3>Data corruption in compiles</h3>
<p>
- Typical symptoms include linker errors, wierd syntax errors or
+ Typical symptoms include linker errors, weird syntax errors or
compiler crashes, caused by corrupt object or source files.
<p>
This has occurred several times in the past, typically because of
@@ -1194,7 +1194,7 @@ understand. Any body know if it work with distcc?
<h3>What is the relationship between Apple Xcode and distcc?</h3>
<p>
Apple's <a href="http://developer.apple.com/tools/xcode/">Xcode</a>
- development kit includes a fork of an old verison of distcc, plus
+ development kit includes a fork of an old version of distcc, plus
Apple patches to locate machines using Rendezvous and a small GUI to
configure it.
<p>
diff --git a/doc/web/man/distcc_1.html b/doc/web/man/distcc_1.html
index 62b91cb..7de1e44 100644
--- a/doc/web/man/distcc_1.html
+++ b/doc/web/man/distcc_1.html
@@ -633,7 +633,7 @@ which cannot be executed remotely, may force the machine to swap,
which reduces performance over just running the jobs in sequence
without swapping. Getting the number of parallel preprocessors
just right allows you to use larger parallel factors with make,
-since the local machine now has some machanism for measuring local
+since the local machine now has some mechanism for measuring local
resource usage.<BR>
<P>
Finally there is the host entry<BR>
diff --git a/doc/web/man/distccd_1.html b/doc/web/man/distccd_1.html
index 4fbaee7..f285d76 100644
--- a/doc/web/man/distccd_1.html
+++ b/doc/web/man/distccd_1.html
@@ -351,7 +351,7 @@ was compiled with</B> <B> Avahi support enabled.</B><BR>
<B>--auth</B>
</DT>
<DD>
-Peform GSS-API based mutual authentication. <B> This option is
+Perform GSS-API based mutual authentication. <B> This option is
only available if distccd was compiled with</B> <B> the --with-auth
configure option.</B><BR>
</DD>
diff --git a/doc/web/man/distccmon_text_1.html b/doc/web/man/distccmon_text_1.html
index 97e77d4..d4fef54 100644
--- a/doc/web/man/distccmon_text_1.html
+++ b/doc/web/man/distccmon_text_1.html
@@ -94,7 +94,7 @@ ID of the distcc client process.<BR>
<DD>
Identifies the phase of operation. In order these may be &quot;Startup&quot;,
&quot;Blocked&quot;, &quot;Connected&quot;, &quot;Preprocess&quot;,
-&quot;Conect&quot;, &quot;Send&quot;, &quot;Receive&quot; and
+&quot;Connect&quot;, &quot;Send&quot;, &quot;Receive&quot; and
&quot;Done&quot;.<BR>
</DD>
<DT>
diff --git a/doc/web/man/include_server_1.html b/doc/web/man/include_server_1.html
index 61d5f17..4802ae4 100644
--- a/doc/web/man/include_server_1.html
+++ b/doc/web/man/include_server_1.html
@@ -114,7 +114,7 @@ other powers of two: see include_server/basics.py.<BR>
</DT>
<DD>
Send email to 'distcc-pump-errors' or if defined, the value of
-enviroment variable DISTCC_EMAILLOG_WHOM_TO_BLAME, when include
+environment variable DISTCC_EMAILLOG_WHOM_TO_BLAME, when include
server gets in trouble. The default is to not send email.<BR>
</DD>
<DT>
diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile
index 5e995d8..df664ee 100644
--- a/docker/base/Dockerfile
+++ b/docker/base/Dockerfile
@@ -1,4 +1,4 @@
-FROM ubuntu:xenial-20170802
+FROM ubuntu:xenial-20210804
LABEL maintainer=""
@@ -7,9 +7,11 @@ ENV DEBIAN_FRONTEND=noninteractive
COPY apt-conf /etc/apt/apt.conf.d/
RUN apt-get update && \
- apt-get install autoconf \
- python3-dev \
- python-dev \
- libiberty-dev \
- build-essential \
- make
+ apt-get install -y autoconf \
+ python3-dev \
+ python-dev \
+ libiberty-dev \
+ build-essential \
+ make \
+ && \
+ rm -rf /var/lib/apt/lists/*
diff --git a/docker/compilers/Dockerfile.clang-3.8 b/docker/compilers/Dockerfile.clang-3.8
index 0c6657c..41f3b54 100644
--- a/docker/compilers/Dockerfile.clang-3.8
+++ b/docker/compilers/Dockerfile.clang-3.8
@@ -3,7 +3,8 @@ FROM distcc/base
LABEL maintainer=""
RUN apt-get update && \
- apt-get install clang-3.8 build-essential && \
+ apt-get install -y clang-3.8 build-essential && \
apt-get remove gcc g++ && \
+ rm -rf /var/lib/apt/lists/* && \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.8 50 && \
update-alternatives --install /usr/bin/cc cc /usr/bin/clang-3.8 50
diff --git a/docker/compilers/Dockerfile.gcc-4.8 b/docker/compilers/Dockerfile.gcc-4.8
index ac227a7..50c0ca9 100644
--- a/docker/compilers/Dockerfile.gcc-4.8
+++ b/docker/compilers/Dockerfile.gcc-4.8
@@ -3,9 +3,10 @@ FROM distcc/base
LABEL maintainer=""
RUN apt-get update && \
- apt-get install gcc-4.8 \
- gcc-multilib \
- g++-4.8 \
- g++-multilib && \
+ apt-get install -y gcc-4.8 \
+ gcc-multilib \
+ g++-4.8 \
+ g++-multilib && \
+ rm -rf /var/lib/apt/lists/* && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 && \
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-4.8 50
diff --git a/docker/compilers/Dockerfile.gcc-5 b/docker/compilers/Dockerfile.gcc-5
index 064ab14..f4febe8 100644
--- a/docker/compilers/Dockerfile.gcc-5
+++ b/docker/compilers/Dockerfile.gcc-5
@@ -3,9 +3,10 @@ FROM distcc/base
LABEL maintainer=""
RUN apt-get update && \
- apt-get install gcc-5 \
- gcc-multilib \
- g++-5 \
- g++-multilib && \
+ apt-get install -y gcc-5 \
+ gcc-multilib \
+ g++-5 \
+ g++-multilib && \
+ rm -rf /var/lib/apt/lists/* && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50 && \
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-5 50
diff --git a/include_server/c_extensions/distcc_pump_c_extensions_module.c b/include_server/c_extensions/distcc_pump_c_extensions_module.c
index 2946df2..763dd42 100644
--- a/include_server/c_extensions/distcc_pump_c_extensions_module.c
+++ b/include_server/c_extensions/distcc_pump_c_extensions_module.c
@@ -211,7 +211,7 @@ XArgv(PyObject *dummy, PyObject *args) {
PyObject *string_object;
string_object = PyList_GetItem(list_object, i); /* borrowed ref */
/* TODO do it properly, catch exceptions for fancy Unicode symbols */
- argv[i] = PyUnicode_AsUTF8(string_object); /* does not increase
+ argv[i] = (char*)PyUnicode_AsUTF8(string_object); /* does not increase
ref count */
}
ret = dcc_x_argv(ifd, "ARGC", "ARGV", argv);
@@ -318,7 +318,7 @@ static PyObject *
Realpath(PyObject *dummy, PyObject *args) {
const char *in;
- /* We explictly allocate memory for the output 'resolved' of 'realpath' --
+ /* We explicitly allocate memory for the output 'resolved' of 'realpath' --
otherwise, some systems will make trouble because they do not accept
passing the second argument NULL (as GNU does) for automatic buffer
allocation. The glib function 'realpath' comes with the warning to not use
diff --git a/include_server/cache_basics.py b/include_server/cache_basics.py
index 8f4ca2e..0832838 100755
--- a/include_server/cache_basics.py
+++ b/include_server/cache_basics.py
@@ -163,7 +163,7 @@ Naming Conventions
that string; 3) a triple of indices; or 4) a pair of indices plus an
assumption that os.getcwd() == currdir.
-Pair Represenation of Filepaths
+Pair Representation of Filepaths
-------------------------------
A file is uniquely determined by the triple
(currdir_idx, searchdir_idx, includepath_idx)
@@ -773,7 +773,7 @@ class BuildStatCache(object):
# If we get here, result is not cached yet.
if __debug__: statistics.sys_stat_counter += 1
- # We do not explictly take into account currdir_idx, because
+ # We do not explicitly take into account currdir_idx, because
# of the check above that os.getcwd is set to current_dir.
relpath = dir_map_string[sl_idx] + includepath
if _OsPathIsFile(relpath):
diff --git a/include_server/include_analyzer.py b/include_server/include_analyzer.py
index b284bbd..32fd429 100755
--- a/include_server/include_analyzer.py
+++ b/include_server/include_analyzer.py
@@ -324,7 +324,7 @@ class IncludeAnalyzer(object):
forcing_files = [d + '/' + special_name
for d in must_exist_dirs]
for forcing_file in forcing_files:
- # If for extremly obscure reasons the file already exists and is useful,
+ # If for extremely obscure reasons the file already exists and is useful,
# then don't change it: that's why we open in "append" mode.
open(forcing_file, "a").close()
return forcing_files
diff --git a/include_server/include_server.py b/include_server/include_server.py
index c03e349..689ed9e 100755
--- a/include_server/include_server.py
+++ b/include_server/include_server.py
@@ -114,11 +114,11 @@ OPTIONS:
includes of absolute filepaths are encountered.
Such includes are then ignored for the purposes of
gathering the include closure. See the
- include_server(1) man page for futher information.
+ include_server(1) man page for further information.
Using this option may lead to incorrect results.
--no_force_dirs Do not force the creation of all directories used
- in an include path. May improve peformance for
+ in an include path. May improve performance for
some cases, but will break builds which use
include structures like "<foo/../file.h>" without
including other files in foo/.
diff --git a/include_server/macro_eval.py b/include_server/macro_eval.py
index 134a54e..9b04ca5 100755
--- a/include_server/macro_eval.py
+++ b/include_server/macro_eval.py
@@ -19,7 +19,7 @@
"""Evaluation of macros acccording to an overapproximation semantics.
-This module generally follows CPP semantics for the evalution of macros. But we
+This module generally follows CPP semantics for the evaluation of macros. But we
treat every define as a possible one, because we don't know whether it is
actually executed when a file is really preprocessed. Our semantics is thus
multi-valued: an expression (that is, a string) is evaluated to the set of
@@ -157,7 +157,7 @@ def _BigUnion(list_of_sets):
def _PrependToSet(expr, expr_set):
- """Return the set consiting of expr + element with element in expr_set."""
+ """Return the set consisting of expr + element with element in expr_set."""
return set([ expr + expr_ for expr_ in expr_set ])
@@ -244,7 +244,7 @@ def _EvalExprHelper(expr, symbol_table, disabled):
"""
def _ReEvalRecursivelyForExpansion(expansion, after):
- """Reevalute the expansion that is the result of finding a match for a
+ """Reevaluate the expansion that is the result of finding a match for a
macro.
Arguments:
@@ -262,7 +262,7 @@ def _EvalExprHelper(expr, symbol_table, disabled):
function-like macro).
The idea is to form a set of strings from a cross product of two string sets
- descriping all possibly expansions before and after the match.
+ describing all possibly expansions before and after the match.
There are two recursions involved. First, we evaluate after to find all
possible values of what follows the match. This recursion does not involve a
diff --git a/include_server/mirror_path_test.py b/include_server/mirror_path_test.py
index 9001de1..bc10e77 100755
--- a/include_server/mirror_path_test.py
+++ b/include_server/mirror_path_test.py
@@ -77,7 +77,7 @@ class MirrorPathTest(unittest.TestCase):
return path in self.links
def realpath(path):
if path.startswith('/root'):
- self.fail("Not expected that '%s' startd with '/root'." % path)
+ self.fail("Not expected that '%s' started with '/root'." % path)
return self.realpaths[path]
def makedirs(path):
if path == '/root/a':
diff --git a/include_server/parse_command.py b/include_server/parse_command.py
index b0b284d..92aff10 100755
--- a/include_server/parse_command.py
+++ b/include_server/parse_command.py
@@ -150,6 +150,7 @@ CPP_OPTIONS_ALWAYS_TWO_WORDS = {
'--param': lambda ps, arg: None,
'-Xassembler': lambda ps, arg: None,
'-Xlinker': lambda ps, arg: None,
+ '-Xclang': lambda ps, arg: None,
}
# For efficiency, it's helpful to be able to combine the two above
diff --git a/include_server/setup.py b/include_server/setup.py
index 1cbc9f6..4ae503e 100755
--- a/include_server/setup.py
+++ b/include_server/setup.py
@@ -21,7 +21,7 @@
The version number should be passed to this script through the environment
variable DISTCC_VERSION. Also, the CPPFLAGS of the Makefile must be passed
-through the enviroment. This is how we figure out the locations of include
+through the environment. This is how we figure out the locations of include
directories. SRCDIR must be passed as well; it explains where to find the C
sources and the include_server directory of Python source files and C
extensions. Because SRCDIR is appended to build location and we don't want to
diff --git a/include_server/test_data/distcc/src/distcc.h b/include_server/test_data/distcc/src/distcc.h
index c0686a7..926be68 100644
--- a/include_server/test_data/distcc/src/distcc.h
+++ b/include_server/test_data/distcc/src/distcc.h
@@ -71,13 +71,13 @@ struct dcc_hostdef;
enum dcc_compress {
- /* wierd values to catch errors */
+ /* weird values to catch errors */
DCC_COMPRESS_NONE = 69,
DCC_COMPRESS_LZO1X
};
enum dcc_cpp_where {
- /* wierd values to catch errors */
+ /* weird values to catch errors */
DCC_CPP_ON_CLIENT = 42,
DCC_CPP_ON_SERVER
};
diff --git a/include_server/test_data/distcc/src/trace.h b/include_server/test_data/distcc/src/trace.h
index 0d99e0f..fcc8a6d 100644
--- a/include_server/test_data/distcc/src/trace.h
+++ b/include_server/test_data/distcc/src/trace.h
@@ -127,7 +127,7 @@ void rs_logger_file(int level, const char *fn, char const *fmt, va_list va,
void rs_logger_syslog(int level, const char *fn, char const *fmt, va_list va,
void *, int);
-/** Check whether the library was compiled with debugging trace suport. */
+/** Check whether the library was compiled with debugging trace support. */
int rs_supports_trace(void);
void rs_log0(int level, char const *fn, char const *fmt, ...)
diff --git a/man/distccd.1 b/man/distccd.1
index 1a3d042..9cf8d1c 100644
--- a/man/distccd.1
+++ b/man/distccd.1
@@ -123,6 +123,13 @@ the machine. NICENESS is an increment to the current priority of the
process. The range of priorities depends on the operating system but
is typically 0 to 20. By default the niceness is increased by 5.
.TP
+.B --oom-score-adj ADJ
+Alters the kernel's out-of-memory killer score adjustment on worker
+processes. ADJ is an integer ranging from -1000 to 1000, with greater
+values indicating a greater preference for killing these processes in an
+out-of-memory scenario. By default the score adjustment is inherited
+from the process that started the distccd daemon. (Linux only.)
+.TP
.B -p, --port PORT
Set the TCP port to listen on, rather than the default of 3632.
(Daemon mode only.)
@@ -232,7 +239,7 @@ that this server can process concurrently.
.B Avahi support enabled.
.TP
.B --auth
-Peform GSS-API based mutual authentication.
+Perform GSS-API based mutual authentication.
.B This option is only available if distccd was compiled with
.B the --with-auth configure option.
.TP
diff --git a/man/distccmon-text.1 b/man/distccmon-text.1
index 4526113..a9e5dce 100644
--- a/man/distccmon-text.1
+++ b/man/distccmon-text.1
@@ -27,7 +27,7 @@ ID of the distcc client process.
.TP
.I STATE
Identifies the phase of operation. In order these may be "Startup",
-"Blocked", "Connected", "Preprocess", "Conect", "Send", "Receive" and
+"Blocked", "Connected", "Preprocess", "Connect", "Send", "Receive" and
"Done".
.TP
.I FILE
diff --git a/packaging/RedHat/conf/clients.allow b/packaging/RedHat/conf/clients.allow
index 4591c2f..991cb53 100644
--- a/packaging/RedHat/conf/clients.allow
+++ b/packaging/RedHat/conf/clients.allow
@@ -17,7 +17,7 @@
# You should only allow trusted hosts to connect to distccd in TCP mode.
# You should assume that any user on the trusted hosts can (with some
# effort) run arbitrary commands as the distcc user on the distccd host.
-# If this is not acceptible, then you should leave this config file empty
+# If this is not acceptable, then you should leave this config file empty
# (apart from comments) and thus only allow SSH mode rather than TCP mode.
# However, be aware that SSH mode has poorer performance than TCP mode.
diff --git a/packaging/googlecode_upload.py b/packaging/googlecode_upload.py
index 9a302b7..ac68fe1 100755
--- a/packaging/googlecode_upload.py
+++ b/packaging/googlecode_upload.py
@@ -199,7 +199,7 @@ def upload(file, project_name, user_name, password, summary, labels=None):
Returns: a tuple:
http_status: 201 if the upload succeeded, something else if an
- error occured.
+ error occurred.
http_reason: The human-readable string associated with http_status
file_url: If the upload succeeded, the URL of the file on Google
Code, None otherwise.
diff --git a/popt/popt.h b/popt/popt.h
index 7f7a26f..bf75042 100644
--- a/popt/popt.h
+++ b/popt/popt.h
@@ -397,8 +397,8 @@ bla=bla
this_is = fdsafdas
bad_line=
- reall bad line
- reall bad line = again
+ really bad line
+ really bad line = again
5555= 55555
test = with lots of spaces
\endverbatim
diff --git a/popt/poptconfig.c b/popt/poptconfig.c
index a600a92..bd8ac57 100644
--- a/popt/poptconfig.c
+++ b/popt/poptconfig.c
@@ -6,6 +6,8 @@
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
+#include <stdint.h>
+
#include "system.h"
#include "poptint.h"
@@ -29,20 +31,20 @@ static void configLine(poptContext con, char * line)
/*@=type@*/
line += nameLength;
- if (*line == '\0' || !isspace(*line)) return;
+ if (*line == '\0' || !isspace((uint8_t)*line)) return;
- while (*line != '\0' && isspace(*line)) line++;
+ while (*line != '\0' && isspace((uint8_t)*line)) line++;
entryType = line;
- while (*line == '\0' || !isspace(*line)) line++;
+ while (*line == '\0' || !isspace((uint8_t)*line)) line++;
*line++ = '\0';
- while (*line != '\0' && isspace(*line)) line++;
+ while (*line != '\0' && isspace((uint8_t)*line)) line++;
if (*line == '\0') return;
opt = line;
- while (*line == '\0' || !isspace(*line)) line++;
+ while (*line == '\0' || !isspace((uint8_t)*line)) line++;
*line++ = '\0';
- while (*line != '\0' && isspace(*line)) line++;
+ while (*line != '\0' && isspace((uint8_t)*line)) line++;
if (*line == '\0') return;
/*@-temptrans@*/ /* FIX: line alias is saved */
@@ -137,7 +139,7 @@ int poptReadConfigFile(poptContext con, const char * fn)
case '\n':
*dst = '\0';
dst = buf;
- while (*dst && isspace(*dst)) dst++;
+ while (*dst && isspace((uint8_t)*dst)) dst++;
if (*dst && *dst != '#')
configLine(con, dst);
chptr++;
diff --git a/popt/popthelp.c b/popt/popthelp.c
index 5448eba..d3dfd49 100644
--- a/popt/popthelp.c
+++ b/popt/popthelp.c
@@ -8,6 +8,7 @@
/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
+#include <stdint.h>
#include "system.h"
#include "poptint.h"
@@ -335,9 +336,9 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
char format[30];
ch = help + lineLength - 1;
- while (ch > help && !isspace(*ch)) ch--;
+ while (ch > help && !isspace((uint8_t)*ch)) ch--;
if (ch == help) break; /* give up */
- while (ch > (help + 1) && isspace(*ch)) ch--;
+ while (ch > (help + 1) && isspace((uint8_t)*ch)) ch--;
ch++;
sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
@@ -345,7 +346,7 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
fprintf(fp, format, help, " ");
/*@=formatconst@*/
help = ch;
- while (isspace(*help) && *help) help++;
+ while (isspace((uint8_t)*help) && *help) help++;
helpLength = strlen(help);
}
/*@=boundsread@*/
diff --git a/popt/poptparse.c b/popt/poptparse.c
index a0dea80..9c98599 100644
--- a/popt/poptparse.c
+++ b/popt/poptparse.c
@@ -5,6 +5,7 @@
/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
+#include <stdint.h>
#include "system.h"
@@ -81,7 +82,7 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
if (*src != quote) *buf++ = '\\';
}
*buf++ = *src;
- } else if (isspace(*src)) {
+ } else if (isspace((uint8_t)*src)) {
if (*argv[argc] != '\0') {
buf++, argc++;
if (argc == argvAlloced) {
@@ -122,7 +123,7 @@ exit:
/*@=bounds@*/
/* still in the dev stage.
- * return values, perhaps 1== file erro
+ * return values, perhaps 1== file error
* 2== line to long
* 3== umm.... more?
*/
@@ -157,7 +158,7 @@ int poptConfigFileToString(FILE *fp, char ** argstrp, /*@unused@*/ int flags)
p = line;
/* loop until first non-space char or EOL */
- while( *p != '\0' && isspace(*p) )
+ while( *p != '\0' && isspace((uint8_t)*p) )
p++;
linelen = strlen(p);
@@ -169,10 +170,10 @@ int poptConfigFileToString(FILE *fp, char ** argstrp, /*@unused@*/ int flags)
q = p;
- while (*q != '\0' && (!isspace(*q)) && *q != '=')
+ while (*q != '\0' && (!isspace((uint8_t)*q)) && *q != '=')
q++;
- if (isspace(*q)) {
+ if (isspace((uint8_t)*q)) {
/* a space after the name, find next non space */
*q++='\0';
while( *q != '\0' && isspace((int)*q) ) q++;
@@ -197,14 +198,14 @@ int poptConfigFileToString(FILE *fp, char ** argstrp, /*@unused@*/ int flags)
*q++ = '\0';
/* find next non-space letter of value */
- while (*q != '\0' && isspace(*q))
+ while (*q != '\0' && isspace((uint8_t)*q))
q++;
if (*q == '\0')
continue; /* XXX silently ignore missing value */
/* now, loop and strip all ending whitespace */
x = p + linelen;
- while (isspace(*--x))
+ while (isspace((uint8_t)*--x))
*x = 0; /* null out last char if space (including fgets() NL) */
/* rest of line accept */
diff --git a/src/arg.c b/src/arg.c
index a132071..6ca5130 100644
--- a/src/arg.c
+++ b/src/arg.c
@@ -262,7 +262,7 @@ int dcc_scan_args(char *argv[], char **input_file, char **output_file,
/* TODO: ccache has the heuristic of ignoring arguments that are not
* extant files when looking for the input file; that's possibly
- * worthwile. Of course we can't do that on the server. */
+ * worthwhile. Of course we can't do that on the server. */
if (!seen_opt_c && !seen_opt_s) {
rs_log_info("compiler apparently called not for compile");
diff --git a/src/argutil.c b/src/argutil.c
index cc71b82..ac61902 100644
--- a/src/argutil.c
+++ b/src/argutil.c
@@ -67,6 +67,19 @@ int dcc_argv_search(char **a,
}
+/**
+ * Return true if argv contains argument starting with needle.
+ */
+int dcc_argv_startswith(char **a,
+ const char *needle)
+{
+ size_t needle_len = strlen(needle);
+ for (; *a; a++)
+ if (!strncmp(*a, needle, needle_len))
+ return 1;
+ return 0;
+}
+
unsigned int dcc_argv_len(char **a)
{
unsigned int i;
@@ -150,7 +163,7 @@ char *dcc_argv_tostr(char **a)
/* kind of half-assed quoting; won't handle strings containing
* quotes properly, but good enough for debug messages for the
* moment. */
- int needs_quotes = (strpbrk(a[i], " \t\n\"\';") != NULL);
+ int needs_quotes = !*a[i] || (strpbrk(a[i], " \t\n\"\';") != NULL);
if (i)
*ss++ = ' ';
if (needs_quotes)
diff --git a/src/auth_distcc.c b/src/auth_distcc.c
index 1a83306..78f68ca 100644
--- a/src/auth_distcc.c
+++ b/src/auth_distcc.c
@@ -262,7 +262,7 @@ static int dcc_gssapi_establish_secure_context(const struct dcc_hostdef *host,
/*
* Attempt handshake exchange with the server to indicate client's
- * desire to authentciate.
+ * desire to authenticate.
*
* @param to_net_sd. Socket to write to.
*
diff --git a/src/auth_distccd.c b/src/auth_distccd.c
index a26d168..a4a58a0 100644
--- a/src/auth_distccd.c
+++ b/src/auth_distccd.c
@@ -238,7 +238,7 @@ static int dcc_gssapi_accept_secure_context(int to_net_sd,
/*
* Attempt handshake exchange with the client to indicate server's
- * desire to authentciate.
+ * desire to authenticate.
*
* @param from_net_sd. Socket to read from.
*
diff --git a/src/backoff.c b/src/backoff.c
index b3d656c..5aaf45a 100644
--- a/src/backoff.c
+++ b/src/backoff.c
@@ -52,6 +52,19 @@
static int dcc_backoff_period = 60; /* seconds */
+static int dcc_get_backoff_period(void)
+{
+ char *bp;
+ bp = getenv("DISTCC_BACKOFF_PERIOD");
+ if (bp)
+ dcc_backoff_period = atoi(bp);
+ return dcc_backoff_period;
+}
+
+int dcc_backoff_is_enabled(void)
+{
+ return dcc_get_backoff_period() != 0;
+}
/**
* Remember that this host is working OK.
@@ -61,23 +74,17 @@ static 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;
+ if (!dcc_backoff_is_enabled())
+ return 0;
return dcc_remove_timefile("backoff", host);
}
int dcc_disliked_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))
+ if (!dcc_backoff_is_enabled())
return 0;
/* i hate you (but only for dcc_backoff_period seconds) */
@@ -108,14 +115,8 @@ 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)
+ if (!dcc_backoff_is_enabled())
return 0;
while ((h = *hostlist) != NULL) {
diff --git a/src/clirpc.c b/src/clirpc.c
index 606f910..fa0dfad 100644
--- a/src/clirpc.c
+++ b/src/clirpc.c
@@ -114,7 +114,7 @@ int dcc_r_result_header(int ifd,
unsigned vers;
int ret;
- if ((ret = dcc_r_token_int(ifd, "DONE", &vers)))
+ if ((ret = dcc_r_token_int(ifd, "DONE", &vers))) {
rs_log_error("server provided no answer. "
"Is the server configured to allow access from your IP"
" address? Is the server performing authentication and"
@@ -122,6 +122,7 @@ int dcc_r_result_header(int ifd,
" installed? Is the server configured to access the"
" compiler?");
return ret;
+ }
if (vers != expect_ver) {
rs_log_error("got version %d not %d in response from server",
diff --git a/src/compile.c b/src/compile.c
index f1fd5c3..e6ef9b9 100644
--- a/src/compile.c
+++ b/src/compile.c
@@ -549,7 +549,7 @@ static void dcc_rewrite_generic_compiler(char **argv)
static void dcc_add_clang_target(char **argv)
{
/* defined by autoheader */
- const char *target = GNU_HOST;
+ const char *target = NATIVE_COMPILER_TRIPLE;
if (strcmp(argv[0], "clang") == 0 || strncmp(argv[0], "clang-", strlen("clang-")) == 0 ||
strcmp(argv[0], "clang++") == 0 || strncmp(argv[0], "clang++-", strlen("clang++-")) == 0)
@@ -557,9 +557,14 @@ static void dcc_add_clang_target(char **argv)
else
return;
+ /* -target aarch64-linux-gnu */
if (dcc_argv_search(argv, "-target"))
return;
+ /* --target=aarch64-linux-gnu */
+ if (dcc_argv_startswith(argv, "--target"))
+ return;
+
rs_log_info("Adding '-target %s' to support clang cross-compilation.",
target);
dcc_argv_append(argv, strdup("-target"));
@@ -572,9 +577,10 @@ static void dcc_add_clang_target(char **argv)
static int dcc_gcc_rewrite_fqn(char **argv)
{
/* defined by autoheader */
- const char *target_with_vendor = GNU_HOST;
+ const char *target_with_vendor = NATIVE_COMPILER_TRIPLE;
char *newcmd, *t, *path;
int pathlen = 0;
+ int newcmd_len = 0;
if (strcmp(argv[0], "gcc") == 0 || strncmp(argv[0], "gcc-", strlen("gcc-")) == 0 ||
strcmp(argv[0], "g++") == 0 || strncmp(argv[0], "g++-", strlen("g++-")) == 0)
@@ -583,15 +589,13 @@ static int dcc_gcc_rewrite_fqn(char **argv)
return -ENOENT;
- newcmd = malloc(strlen(target_with_vendor) + 1 + strlen(argv[0] + 1));
+ newcmd_len = strlen(target_with_vendor) + 1 + strlen(argv[0]) + 1;
+ newcmd = malloc(newcmd_len);
if (!newcmd)
return -ENOMEM;
+ memset(newcmd, 0, newcmd_len);
- if ((t = strstr(target_with_vendor, "-pc-"))) {
- memcpy(newcmd, target_with_vendor, t - target_with_vendor);
- strcat(newcmd, t + strlen("-pc"));
- } else
- strcpy(newcmd, target_with_vendor);
+ strcpy(newcmd, target_with_vendor);
strcat(newcmd, "-");
@@ -628,6 +632,18 @@ static int dcc_gcc_rewrite_fqn(char **argv)
return -ENOENT;
}
+static int dcc_get_max_retries(void)
+{
+ if (dcc_backoff_is_enabled()) {
+ /* eventually distcc will either find a suitable host or mark
+ * all hosts as faulty (and fallback to a local compilation)
+ */
+ return 0; /* no limit */
+ } else {
+ return 3; /* somewhat arbitrary */
+ }
+}
+
/**
* Execute the commands in argv remotely or locally as appropriate.
*
@@ -684,10 +700,13 @@ dcc_build_somewhere(char *argv[],
int cpu_lock_fd = -1, local_cpu_lock_fd = -1;
int ret;
int remote_ret = 0;
+ int retry_count = 0, max_retries;
struct dcc_hostdef *host = NULL;
char *discrepancy_filename = NULL;
char **new_argv;
+ max_retries = dcc_get_max_retries();
+
if ((ret = dcc_expand_preprocessor_options(&argv)) != 0)
goto clean_up;
@@ -838,7 +857,14 @@ dcc_build_somewhere(char *argv[],
/* dcc_compile_remote() already unlocked local_cpu_lock_fd. */
local_cpu_lock_fd = -1;
bad_host(host, &cpu_lock_fd, &local_cpu_lock_fd);
- goto choose_host;
+ retry_count++;
+ if (max_retries == 0 || retry_count < max_retries)
+ goto choose_host;
+ else {
+ rs_log_warning("Couldn't find a host in %d attempts, retrying locally",
+ retry_count);
+ goto fallback;
+ }
}
/* dcc_compile_remote() already unlocked local_cpu_lock_fd. */
local_cpu_lock_fd = -1;
diff --git a/src/daemon.c b/src/daemon.c
index 5f30715..ff84d97 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -170,6 +170,12 @@ static void dcc_warn_masquerade_whitelist(void) {
rs_log_crit(LIBDIR "/distcc empty. %s", warn);
dcc_exit(EXIT_COMPILER_MISSING);
}
+ if (d) {
+ closedir(d);
+ }
+ if (e) {
+ closedir(e);
+ }
}
/**
diff --git a/src/distcc.h b/src/distcc.h
index 7860a2c..d4f6334 100644
--- a/src/distcc.h
+++ b/src/distcc.h
@@ -190,6 +190,7 @@ int dcc_support_masquerade(char *argv[], char *progname, int *);
int dcc_enjoyed_host(const struct dcc_hostdef *host);
int dcc_disliked_host(const struct dcc_hostdef *host);
int dcc_remove_disliked(struct dcc_hostdef **hostlist);
+int dcc_backoff_is_enabled(void);
@@ -262,6 +263,7 @@ int dcc_expand_preprocessor_options(char ***argv_ptr);
/* argutil.c */
unsigned int dcc_argv_len(char **a);
int dcc_argv_search(char **a, const char *);
+int dcc_argv_startswith(char **a, const char *);
int dcc_copy_argv(char **argv, char ***out_argv, int extra_args);
int dcc_argv_append(char **argv, char *toadd);
char *dcc_argv_tostr(char **a);
diff --git a/src/dopt.c b/src/dopt.c
index d680ad5..71e5ae7 100644
--- a/src/dopt.c
+++ b/src/dopt.c
@@ -33,6 +33,7 @@
#include <fcntl.h>
#include <errno.h>
#include <popt.h>
+#include <limits.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -49,6 +50,10 @@
int opt_niceness = 5; /* default */
+#ifdef HAVE_LINUX
+int opt_oom_score_adj = INT_MIN; /* default is not to change */
+#endif
+
/**
* Number of children running jobs on this machine. If zero (recommended),
* then dynamically set from the number of CPUs.
@@ -154,6 +159,9 @@ const struct poptOption options[] = {
{ "no-detach", 0, POPT_ARG_NONE, &opt_no_detach, 0, 0, 0 },
{ "no-fifo", 0, POPT_ARG_NONE, &opt_no_fifo, 0, 0, 0 },
{ "no-fork", 0, POPT_ARG_NONE, &opt_no_fork, 0, 0, 0 },
+#ifdef HAVE_LINUX
+ { "oom-score-adj",0, POPT_ARG_INT, &opt_oom_score_adj, 0, 0, 0 },
+#endif
{ "pid-file", 'P', POPT_ARG_STRING, &arg_pid_file, 0, 0, 0 },
{ "port", 'p', POPT_ARG_INT, &arg_port, 0, 0, 0 },
#ifdef HAVE_GSSAPI
@@ -191,6 +199,9 @@ static void distccd_show_usage(void)
#endif
" -P, --pid-file FILE save daemon process id to file\n"
" -N, --nice LEVEL lower priority, 20=most nice\n"
+#ifdef HAVE_LINUX
+" --oom-score-adj ADJ set OOM score adjustment, -1000 to 1000\n"
+#endif
" --user USER if run by root, change to this persona\n"
" --jobs, -j LIMIT maximum tasks at any time\n"
" --job-lifetime SECONDS maximum lifetime of a compile request\n"
@@ -298,8 +309,8 @@ int distccd_parse_options(int argc, const char **argv)
#endif
case 'j':
- if (arg_max_jobs < 1 || arg_max_jobs > 200) {
- rs_log_error("--jobs argument must be between 1 and 200");
+ if (arg_max_jobs < 1 ) {
+ rs_log_error("--jobs argument must be more than 0");
exitcode = EXIT_BAD_ARGUMENTS;
goto out_exit;
}
diff --git a/src/dopt.h b/src/dopt.h
index 70db3ca..139167b 100644
--- a/src/dopt.h
+++ b/src/dopt.h
@@ -46,6 +46,10 @@ extern int opt_lifetime;
extern char *opt_listen_addr;
extern int opt_niceness;
+#ifdef HAVE_LINUX
+extern int opt_oom_score_adj;
+#endif
+
#ifdef HAVE_AVAHI
extern int opt_zeroconf;
#endif
diff --git a/src/hosts.c b/src/hosts.c
index 80ee2d7..065b287 100644
--- a/src/hosts.c
+++ b/src/hosts.c
@@ -222,7 +222,7 @@ static int dcc_parse_multiplier(const char **psrc, struct dcc_hostdef *hostdef)
rs_log_error("bad multiplier \"%s\" in host specification", token);
return EXIT_BAD_HOSTSPEC;
}
- while (isdigit(**psrc))
+ while (isdigit((uint8_t)**psrc))
(*psrc)++;
hostdef->n_slots = val;
}
@@ -380,7 +380,7 @@ static int dcc_parse_tcp_host(struct dcc_hostdef *hostdef,
token++;
hostdef->port = strtol(token, &tail, 10);
- if (*tail != '\0' && !isspace(*tail) && *tail != '/' && *tail != ',') {
+ if (*tail != '\0' && !isspace((uint8_t)*tail) && *tail != '/' && *tail != ',') {
rs_log_error("invalid tcp port specification in \"%s\"", token);
return EXIT_BAD_HOSTSPEC;
} else {
@@ -521,7 +521,7 @@ int dcc_parse_hosts(const char *where, const char *source_name,
continue;
}
- if (isspace(where[0])) {
+ if (isspace((uint8_t)where[0])) {
where++; /* skip space */
continue;
}
diff --git a/src/io.c b/src/io.c
index df726e8..6be3b3f 100644
--- a/src/io.c
+++ b/src/io.c
@@ -261,8 +261,8 @@ int dcc_writex(int fd, const void *buf, size_t len)
int tcp_cork_sock(int POSSIBLY_UNUSED(fd), int POSSIBLY_UNUSED(corked))
{
#if defined(TCP_CORK) && defined(SOL_TCP)
- if (!dcc_getenv_bool("DISTCC_TCP_CORK", 1) || !(sd_is_socket(fd, AF_INET, SOCK_STREAM, 1) ||
- sd_is_socket(fd, AF_INET6, SOCK_STREAM, 1)))
+ if (!dcc_getenv_bool("DISTCC_TCP_CORK", 1) || !(not_sd_is_socket(fd, AF_INET, SOCK_STREAM, 1) ||
+ not_sd_is_socket(fd, AF_INET6, SOCK_STREAM, 1)))
return 0;
if (setsockopt(fd, SOL_TCP, TCP_CORK, &corked, sizeof corked) == -1) {
diff --git a/src/loadfile.c b/src/loadfile.c
index a692b72..b82e775 100644
--- a/src/loadfile.c
+++ b/src/loadfile.c
@@ -61,7 +61,7 @@ int dcc_load_file_string(const char *filename,
/* Open the file */
if ((fd = open(filename, O_RDONLY)) == -1) {
- if (errno == EEXIST)
+ if (errno == ENOENT)
return EXIT_NO_SUCH_FILE;
else {
rs_log_warning("failed to open %s: %s", filename,
diff --git a/src/mon-gnome.c b/src/mon-gnome.c
index bfc286d..9a334b5 100644
--- a/src/mon-gnome.c
+++ b/src/mon-gnome.c
@@ -97,45 +97,39 @@ enum {
};
-/**
- * Graphics contexts to be used to draw each particular state into the
- * model.
- **/
-GdkGC *dcc_phase_gc[DCC_PHASE_DONE];
-
-
-#if 0
-/* shades of red */
-const GdkColor task_color[] = {
- { 0, 0x2222, 0, 0 }, /* DCC_PHASE_STARTUP, */
- { 0, 0x4444, 0, 0 }, /* DCC_PHASE_BLOCKED, */
- { 0, 0x6666, 0, 0 }, /* DCC_PHASE_CONNECT, */
- { 0, 0x8888, 0, 0 }, /* DCC_PHASE_CPP, */
- { 0, 0xaaaa, 0, 0 }, /* DCC_PHASE_SEND, */
- { 0, 0xcccc, 0, 0 }, /* DCC_PHASE_COMPILE, */
- { 0, 0xeeee, 0, 0 }, /* DCC_PHASE_RECEIVE, */
- { 0, 0xffff, 0xffff, 0 }, /* DCC_PHASE_DONE */
-};
-#endif
-
/*
- * Colors used for drawing different state stripes. First GdkColor
- * field is the assigned color index and zero here.
+ * Colors used for drawing different state stripes.
*
* These color names are from the GNOME standard palette.
*/
-const GdkColor task_color[] = {
- { 0, 0x9999, 0, 0 }, /* DCC_PHASE_STARTUP, accent red dark */
- { 0, 0x9999, 0, 0 }, /* DCC_PHASE_BLOCKED, accent red dark */
- { 0, 0xc1c1, 0x6666, 0x5a5a }, /* DCC_PHASE_CONNECT, red medium */
- { 0, 0x8888, 0x7f7f, 0xa3a3 }, /* DCC_PHASE_CPP, purple medium*/
- { 0, 0xe0e0, 0xc3c3, 0x9e9e }, /* DCC_PHASE_SEND, face skin medium*/
- { 0, 0x8383, 0xa6a6, 0x7f7f }, /* DCC_PHASE_COMPILE, green medium */
- { 0, 0x7575, 0x9090, 0xaeae }, /* DCC_PHASE_RECEIVE, blue medium*/
- { 0, 0, 0, 0 }, /* DCC_PHASE_DONE */
+GdkRGBA task_color[DCC_PHASE_DONE];
+
+const char * task_color_string[] = {
+ "#999900000000", /* DCC_PHASE_STARTUP, accent red dark */
+ "#999900000000", /* DCC_PHASE_BLOCKED, accent red dark */
+ "#c1c166665a5a", /* DCC_PHASE_CONNECT, red medium */
+ "#88887f7fa3a3", /* DCC_PHASE_CPP, purple medium*/
+ "#e0e0c3c39e9e", /* DCC_PHASE_SEND, face skin medium*/
+ "#8383a6a67f7f", /* DCC_PHASE_COMPILE, green medium */
+ "#75759090aeae", /* DCC_PHASE_RECEIVE, blue medium*/
+ "#000000000000", /* DCC_PHASE_DONE */
};
+/**
+ * Initialize rgba colors for drawing in the right color for each state.
+ **/
+static void
+dcc_create_state_colors (void)
+{
+ enum dcc_phase i_state;
+ for (i_state = 0; i_state <= DCC_PHASE_DONE; i_state++)
+ {
+ gdk_rgba_parse(&task_color[i_state],task_color_string[i_state]);
+ }
+}
+
+
static void
dcc_setup_tree_model (void)
{
@@ -446,38 +440,19 @@ static gint dcc_gnome_load_update_cb (gpointer data)
/**
- * Initialize graphics context for drawing into a widget in the right
- * color for each state.
- **/
-static void
-dcc_create_state_gcs (GtkWidget *widget)
-{
- enum dcc_phase i_state;
-
- for (i_state = 0; i_state < DCC_PHASE_DONE; i_state++)
- {
- dcc_phase_gc[i_state] = gdk_gc_new (widget->window);
- gdk_gc_set_rgb_fg_color (dcc_phase_gc[i_state],
- (GdkColor *) &task_color[i_state]);
-
- }
-}
-
-
-/**
* Configure GtkTreeView with the right columns bound to
* renderers, and a data model.
**/
static void dcc_gnome_make_proc_view (GtkTreeModel *proc_model,
- GtkWidget **align_return)
+ GtkWidget **widget_return)
{
GtkCellRenderer *text_renderer, *chart_renderer;
GtkTreeSelection *selection;
GtkTreeViewColumn *column;
- GtkWidget *align, *proc_scroll;
+ GtkWidget *proc_scroll;
chart_treeview = gtk_tree_view_new_with_model (proc_model);
- gtk_object_set (GTK_OBJECT (chart_treeview),
+ g_object_set (G_OBJECT (chart_treeview),
"headers-visible", TRUE,
NULL);
@@ -485,10 +460,6 @@ static void dcc_gnome_make_proc_view (GtkTreeModel *proc_model,
gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
- /* we can't create the gcs until the widget is first realized */
- g_signal_connect_after (chart_treeview, "realize",
- G_CALLBACK (dcc_create_state_gcs), NULL);
-
text_renderer = gtk_cell_renderer_text_new ();
chart_renderer = dcc_cell_renderer_chart_new ();
@@ -544,11 +515,7 @@ static void dcc_gnome_make_proc_view (GtkTreeModel *proc_model,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (proc_scroll), chart_treeview);
- /* Expands to fill all space */
- align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
- gtk_container_add (GTK_CONTAINER (align), proc_scroll);
-
- *align_return = align;
+ *widget_return = proc_scroll;
}
@@ -558,6 +525,8 @@ static GtkWidget * dcc_gnome_make_load_bar (void)
gint context_id;
bar = gtk_statusbar_new ();
+ gtk_widget_set_margin_top(GTK_WIDGET(bar), 0);
+ gtk_widget_set_margin_bottom(GTK_WIDGET(bar), 0);
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR (bar), "load");
gtk_statusbar_push(GTK_STATUSBAR (bar), context_id, "Load: ");
@@ -592,9 +561,9 @@ static GtkWidget * dcc_gnome_make_mainwin (void)
gtk_window_set_default_size (GTK_WINDOW (mainwin), 500, 300);
/* Quit when it's closed */
- g_signal_connect (GTK_OBJECT(mainwin), "delete-event",
+ g_signal_connect (G_OBJECT(mainwin), "delete-event",
G_CALLBACK (gtk_main_quit), NULL);
- g_signal_connect (GTK_OBJECT(mainwin), "destroy",
+ g_signal_connect (G_OBJECT(mainwin), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
#if GTK_CHECK_VERSION(2,2,0)
@@ -615,8 +584,9 @@ static int dcc_gnome_make_app (void)
/* Create the main window */
mainwin = dcc_gnome_make_mainwin ();
- /* Create a vbox for the contents */
- topbox = gtk_vbox_new (FALSE, 0);
+ /* Create a gtkbox for the contents */
+ topbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+
gtk_container_add (GTK_CONTAINER (mainwin),
topbox);
@@ -628,6 +598,13 @@ static int dcc_gnome_make_app (void)
gtk_container_add (GTK_CONTAINER (topbox),
proc_align);
+ gtk_box_set_child_packing (GTK_BOX (topbox),
+ GTK_WIDGET (proc_align),
+ TRUE,
+ TRUE,
+ 0,
+ GTK_PACK_START);
+
gtk_box_pack_end (GTK_BOX (topbox),
load_bar,
FALSE, /* expand */
@@ -653,17 +630,10 @@ int main(int argc, char **argv)
* compilation */
nice(5);
-#if defined(WITH_GNOME)
- gnome_program_init ("distccmon-gnome", PACKAGE_VERSION,
- LIBGNOMEUI_MODULE,
- argc, argv, NULL);
-#elif defined(WITH_GTK)
gtk_init (&argc, &argv);
-#else
-# error This program must be built with either WITH_GTK or WITH_GNOME
-#endif
/* do our own initialization */
+ dcc_create_state_colors();
dcc_gnome_make_app ();
/* Keep running until quit */
diff --git a/src/prefork.c b/src/prefork.c
index 38e3a19..d4d70d5 100644
--- a/src/prefork.c
+++ b/src/prefork.c
@@ -37,6 +37,8 @@
#include <syslog.h>
#include <signal.h>
#include <fcntl.h>
+#include <time.h>
+#include <limits.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -91,10 +93,6 @@ int dcc_preforking_parent(int listen_fd)
/* wait for any children to exit, and then start some more */
dcc_reap_kids(TRUE);
-
- /* Another little safety brake here: since children should not exit
- * too quickly, pausing before starting them should be harmless. */
- sleep(1);
}
}
}
@@ -133,10 +131,6 @@ static void dcc_create_kids(int listen_fd) {
++dcc_nkids;
rs_trace("up to %d children", dcc_nkids);
}
-
- /* Don't start them too quickly, or we might overwhelm a machine
- * that's having trouble. */
- sleep(1);
}
}
@@ -151,9 +145,22 @@ static void dcc_create_kids(int listen_fd) {
static int dcc_preforked_child(int listen_fd)
{
int ireq;
- const int child_lifetime = 50;
+ time_t start, now;
+ const int child_requests = 50;
+ const time_t child_lifetime = 60 /* seconds */;
+ start = now = time(NULL);
+
+#ifdef HAVE_LINUX
+ if (opt_oom_score_adj != INT_MIN) {
+ FILE *f = fopen("/proc/self/oom_score_adj", "w");
+ if (!f || fprintf(f, "%d\n", opt_oom_score_adj) < 0)
+ rs_log_warning("failed to set oom_score_adj: %s", strerror(errno));
+ if (f)
+ fclose(f);
+ }
+#endif
- for (ireq = 0; ireq < child_lifetime; ireq++) {
+ for (ireq = 0; ireq < child_requests || now - start < child_lifetime; ireq++) {
int acc_fd;
struct dcc_sockaddr_storage cli_addr;
socklen_t cli_len;
@@ -188,6 +195,7 @@ static int dcc_preforked_child(int listen_fd)
(struct sockaddr *) &cli_addr, cli_len);
dcc_close(acc_fd);
+ now = time(NULL);
}
rs_log_info("worn out");
diff --git a/src/renderer.c b/src/renderer.c
index ca329fa..880ff07 100644
--- a/src/renderer.c
+++ b/src/renderer.c
@@ -160,18 +160,17 @@ dcc_cell_renderer_chart_get_property (GObject *object,
**/
static void
dcc_cell_renderer_chart_render (GtkCellRenderer *cell,
- GdkWindow *window,
+ cairo_t *cr,
GtkWidget *UNUSED(widget),
- GdkRectangle *UNUSED(background_area),
- GdkRectangle *cell_area,
- GdkRectangle *UNUSED(expose_area),
+ const GdkRectangle *UNUSED(background_area),
+ const GdkRectangle *cell_area,
GtkCellRendererState UNUSED(flags))
{
const struct dcc_history *history;
enum dcc_phase state;
int x1, y1;
- int bar_height;
- int bar_width;
+ int bar_height, bar_width;
+ int xpad, ypad;
int i;
const enum dcc_phase *phases;
@@ -179,10 +178,10 @@ dcc_cell_renderer_chart_render (GtkCellRenderer *cell,
history = cellchart->history;
g_return_if_fail (history); /* Perhaps we should just ignore this.. */
-
- x1 = cell_area->x + cell->xpad;
- y1 = cell_area->y + cell->ypad;
- bar_height = cell_area->height - (2 * cell->ypad);
+ gtk_cell_renderer_get_padding(cell, &xpad, &ypad);
+ x1 = cell_area->x + xpad;
+ y1 = cell_area->y + ypad;
+ bar_height = cell_area->height - (2 * ypad);
/* bar width is chosen such that the history roughly fills the cell
(but it must be at least 1). We use the full history, not just
@@ -200,10 +199,9 @@ dcc_cell_renderer_chart_render (GtkCellRenderer *cell,
if (state != DCC_PHASE_DONE)
{
- gdk_draw_rectangle (window,
- dcc_phase_gc[state],
- TRUE, /* fill */
- x1, y1, bar_width, bar_height);
+ gdk_cairo_set_source_rgba (cr, &task_color[state]);
+ cairo_rectangle (cr, x1, y1, bar_width, bar_height);
+ cairo_fill (cr);
}
x1 += bar_width;
@@ -212,26 +210,10 @@ dcc_cell_renderer_chart_render (GtkCellRenderer *cell,
-/**
- * Measure the size that we want to have allocated for this cell.
- */
-static void
-dcc_cell_renderer_chart_get_size (GtkCellRenderer *UNUSED(cell),
- GtkWidget *UNUSED (widget),
- GdkRectangle *UNUSED (cell_area),
- gint *UNUSED (x_offset),
- gint *UNUSED (y_offset),
- gint *UNUSED (width),
- gint *UNUSED (height))
-{
- /* default is fine */
-}
-
-
-
static void
-dcc_cell_renderer_chart_class_init (DccCellRendererChartClass *class)
+dcc_cell_renderer_chart_class_init (DccCellRendererChartClass *class,
+ gpointer UNUSED(klass))
{
GParamSpec *spec;
@@ -242,7 +224,6 @@ dcc_cell_renderer_chart_class_init (DccCellRendererChartClass *class)
object_class->set_property = dcc_cell_renderer_chart_set_property;
cell_class->render = dcc_cell_renderer_chart_render;
- cell_class->get_size = dcc_cell_renderer_chart_get_size;
spec = g_param_spec_pointer ("history",
"Slot history",
@@ -257,7 +238,8 @@ dcc_cell_renderer_chart_class_init (DccCellRendererChartClass *class)
/* Instance initialization */
static void
-dcc_cell_renderer_chart_init (DccCellRendererChart *cell)
+dcc_cell_renderer_chart_init (DccCellRendererChart *cell,
+ gpointer UNUSED(klass))
{
cell->history = NULL;
}
@@ -277,20 +259,20 @@ dcc_cell_renderer_chart_get_type (void)
{
static const GTypeInfo cell_chart_info =
{
- sizeof (DccCellRendererChartClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) dcc_cell_renderer_chart_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (DccCellRendererChart),
- 0, /* n_preallocs */
- (GInstanceInitFunc) dcc_cell_renderer_chart_init,
- NULL /* value_table */
+ sizeof (DccCellRendererChartClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) dcc_cell_renderer_chart_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (DccCellRendererChart),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) dcc_cell_renderer_chart_init,
+ NULL /* value_table */
};
cell_chart_type =
- g_type_register_static (GTK_TYPE_CELL_RENDERER,
+ g_type_register_static (GTK_TYPE_CELL_RENDERER,
"DccCellRendererChart",
&cell_chart_info, 0);
}
diff --git a/src/renderer.h b/src/renderer.h
index 8246040..41185b3 100644
--- a/src/renderer.h
+++ b/src/renderer.h
@@ -42,7 +42,5 @@ typedef struct _DccCellRendererChartClass DccCellRendererChartClass;
GType dcc_cell_renderer_chart_get_type (void);
GtkCellRenderer *dcc_cell_renderer_chart_new (void);
-
-extern GdkGC *dcc_phase_gc[DCC_PHASE_DONE];
-
extern const guint dcc_max_history_queue;
+extern GdkRGBA task_color[];
diff --git a/src/rpc.c b/src/rpc.c
index 111b86a..d3be08d 100644
--- a/src/rpc.c
+++ b/src/rpc.c
@@ -37,6 +37,7 @@
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
+#include <stdint.h>
#include <sys/stat.h>
@@ -142,7 +143,7 @@ int dcc_explain_mismatch(const char *buf,
extrabuf[l] = '\0';
for (p = extrabuf; *p; p++)
- if (!(isprint(*p) || *p == ' ' || *p == '\t')) {
+ if (!(isprint((uint8_t)*p) || *p == ' ' || *p == '\t')) {
*p = '\0';
break;
}
diff --git a/src/serve.c b/src/serve.c
index 8fe4966..7dd4647 100644
--- a/src/serve.c
+++ b/src/serve.c
@@ -395,16 +395,13 @@ static int dcc_check_compiler_whitelist(char *_compiler_name)
#ifdef HAVE_FSTATAT
int dirfd = open(LIBDIR "/distcc", O_RDONLY);
- if (dirfd < 0) {
- if (errno == ENOENT)
- rs_log_crit("no %s", LIBDIR "/distcc");
- return EXIT_DISTCC_FAILED;
- }
- if (faccessat(dirfd, compiler_name, X_OK, 0) < 0) {
+ if (dirfd < 0 || faccessat(dirfd, compiler_name, X_OK, 0) < 0) {
char *compiler_path = NULL;
- if (asprintf(&compiler_path, "/usr/lib/distcc/%s", compiler_name) && compiler_path) {
+ if (asprintf(&compiler_path, "/usr/lib/distcc/%s", compiler_name) >= 0) {
if (access(compiler_path, X_OK) < 0) {
+ free(compiler_path);
+ close(dirfd);
rs_log_crit("%s not in %s or %s whitelist.", compiler_name, LIBDIR "/distcc", "/usr/lib/distcc");
return EXIT_BAD_ARGUMENTS; /* ENOENT, EACCESS, etc */
}
@@ -412,31 +409,33 @@ static int dcc_check_compiler_whitelist(char *_compiler_name)
}
}
+ close(dirfd);
+
rs_trace("%s in" LIBDIR "/distcc whitelist", compiler_name);
return 0;
#else
// make do with access():
- char *compiler_path = NULL;
+ char *compiler_path;
int ret = 0;
- if (asprintf(&compiler_path, "%s/distcc/%s", LIBDIR, compiler_name) && compiler_path) {
+ if (asprintf(&compiler_path, "%s/distcc/%s", LIBDIR, compiler_name) >= 0) {
if (access(compiler_path, X_OK) < 0) {
free(compiler_path);
/* check /usr/lib/distcc too */
- if (asprintf(&compiler_path, "/usr/lib/distcc/%s", compiler_name) && compiler_path) {
+ if (asprintf(&compiler_path, "/usr/lib/distcc/%s", compiler_name) >= 0) {
if (access(compiler_path, X_OK) < 0) {
rs_log_crit("%s not in %s or %s whitelist.", compiler_name, LIBDIR "/distcc", "/usr/lib/distcc");
ret = EXIT_BAD_ARGUMENTS; /* ENOENT, EACCESS, etc */
}
+ free(compiler_path);
}
- }
+ } else {
+ free(compiler_path);
+ }
rs_trace("%s in" LIBDIR "/distcc whitelist", compiler_name);
} else {
rs_log_crit("Couldn't check if %s is in %s whitelist.", compiler_name, LIBDIR "/distcc");
ret = EXIT_DISTCC_FAILED;
}
- if (compiler_path) {
- free(compiler_path);
- }
return ret;
#endif
}
@@ -533,7 +532,7 @@ static int tweak_include_arguments_for_server(char **argv,
* it augments, rather than replace, the list of targets in the dotd file.
* The behavior we want though, is the replacing behavior.
* So here we delete the "-MT target" arguments, and we return the target,
- * for use in the .d rewritting in dotd.c.
+ * for use in the .d rewriting in dotd.c.
*/
static int dcc_convert_mt_to_dotd_target(char **argv, char **dotd_target)
{
@@ -591,7 +590,9 @@ static int tweak_arguments_for_server(char **argv,
if ((ret = dcc_convert_mt_to_dotd_target(*tweaked_argv, dotd_target)))
return 1;
- dcc_argv_append(*tweaked_argv, strdup("-MMD"));
+ if (!dcc_argv_search(*tweaked_argv, "-MD") && !dcc_argv_search(*tweaked_argv, "-MMD")) {
+ dcc_argv_append(*tweaked_argv, strdup("-MMD"));
+ }
dcc_argv_append(*tweaked_argv, strdup("-MF"));
dcc_argv_append(*tweaked_argv, strdup(deps_fname));
diff --git a/src/setuid.c b/src/setuid.c
index d664b84..44bc850 100644
--- a/src/setuid.c
+++ b/src/setuid.c
@@ -139,6 +139,15 @@ int dcc_discard_root(void)
return EXIT_SETUID_FAILED;
}
+#ifdef HAVE_LINUX
+ /* On Linux changing the effective user or group ID clears the process's
+ * "dumpable" flag, which makes all files in the /proc/self/ directory
+ * owned by root and therefore unmodifiable by the process itself.
+ * Set the flag again here so we can, e.g., change oom_score_adj. */
+ if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0)
+ rs_log_warning("failed to restore dumpable process flag: %s", strerror(errno));
+#endif
+
#ifdef __linux__
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) == 0)
rs_trace("successfully set no_new_privs");
diff --git a/src/snprintf.c b/src/snprintf.c
index f6c5a54..b229e7e 100644
--- a/src/snprintf.c
+++ b/src/snprintf.c
@@ -78,7 +78,7 @@
* Fix incorrect zpadlen handling in fmtfp.
* Thanks to Ollie Oldham <ollie.oldham@metro-optix.com> for spotting it.
* few mods to make it easier to compile the tests.
- * addedd the "Ollie" test to the floating point ones.
+ * added the "Ollie" test to the floating point ones.
*
* Martin Pool (mbp@samba.org) April 2003
* Remove NO_CONFIG_H so that the test case can be built within a source
diff --git a/src/strip.c b/src/strip.c
index 1d6a591..4a1af52 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -93,7 +93,8 @@ int dcc_strip_local_args(char **from, char ***out_argv)
|| str_equal("-iwithprefix", from[from_i])
|| str_equal("-isystem", from[from_i])
|| str_equal("-iwithprefixbefore", from[from_i])
- || str_equal("-idirafter", from[from_i])) {
+ || str_equal("-idirafter", from[from_i])
+ || str_equal("-Xpreprocessor", from[from_i])) {
/* skip next word, being option argument */
if (from[from_i+1])
from_i++;
diff --git a/src/tempfile.c b/src/tempfile.c
index 6890efb..9c46afe 100644
--- a/src/tempfile.c
+++ b/src/tempfile.c
@@ -52,6 +52,7 @@
#ifdef __CYGWIN32__
#define NOGDI
+ #define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
diff --git a/src/util.c b/src/util.c
index 41832d6..9eb4337 100644
--- a/src/util.c
+++ b/src/util.c
@@ -183,7 +183,7 @@ int dcc_getenv_bool(const char *name, int default_value)
}
-#define IS_LEGAL_DOMAIN_CHAR(c) (isalnum(c) || ((c) == '-') || ((c) == '.'))
+#define IS_LEGAL_DOMAIN_CHAR(c) (isalnum((uint8_t)c) || ((c) == '-') || ((c) == '.'))
/* Copy domain part of hostname to static buffer.
* If hostname has no domain part, returns -1.
@@ -831,7 +831,7 @@ int dcc_tokenize_string(const char *input, char ***argv_ptr)
/* Count the spaces in the string. */
for (for_count = input_copy; *for_count; for_count++)
- if (isspace(*for_count))
+ if (isspace((uint8_t)*for_count))
n_spaces++;
/* The maximum number of space-delimited strings we
@@ -989,7 +989,7 @@ union sockaddr_union {
struct sockaddr_storage storage;
};
-int sd_is_socket(int fd, int family, int type, int listening) {
+int not_sd_is_socket(int fd, int family, int type, int listening) {
int r;
if (family < 0)
diff --git a/src/util.h b/src/util.h
index f9a4839..cf9a09a 100644
--- a/src/util.h
+++ b/src/util.h
@@ -24,6 +24,7 @@
#include <setjmp.h>
#include <stdio.h>
#include <time.h>
+#include <stdint.h>
/* util.c */
int dcc_timecmp(struct timeval a, struct timeval b);
@@ -63,4 +64,4 @@ int dcc_tokenize_string(const char *in, char ***argv_ptr);
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
#endif
-int sd_is_socket(int fd, int family, int type, int listening);
+int not_sd_is_socket(int fd, int family, int type, int listening);
diff --git a/test/testdistcc.py b/test/testdistcc.py
index 767c947..dfdf2f1 100755
--- a/test/testdistcc.py
+++ b/test/testdistcc.py
@@ -45,7 +45,7 @@ Example:
# invocation of a test: this means each method runs just once and so
# object state is not very useful, but nevermind.
-# Having a complicated pattens of up and down-calls within the class
+# Having a complicated patterns of up and down-calls within the class
# methods seems to make things more complicated. It may be better if
# abstract superclasses just provide methods that can be called,
# rather than establishing default behaviour.
@@ -1256,7 +1256,6 @@ class Gdb_Case(CompileHello_Case):
"""Return command to compile source"""
os.mkdir("obj")
return self.distcc_without_fallback() + self.compiler() + \
- self.build_id + \
" -o obj/testtmp.o -I. -c %s" % (self.sourceFilename())
def link(self):
@@ -1610,9 +1609,7 @@ class DashMD_DashMF_DashMT_Case(CompileHello_Case):
"""Test -MD -MFfoo -MTbar"""
def compileOpts(self):
- opts = "-MD -MFdotd_filename -MTtarget_name_42"
- opts += " -Qunused-arguments" if self.is_clang(self._cc) else ""
- return opts
+ return "-MD -MFdotd_filename -MTtarget_name_42"
def runtest(self):
try:
@@ -1628,9 +1625,7 @@ class DashWpMD_Case(CompileHello_Case):
"""Test -Wp,-MD,depfile"""
def compileOpts(self):
- opts = "-Wp,-MD,depsfile"
- opts += " -Qunused-arguments" if self.is_clang(self._cc) else ""
- return opts
+ return "-Wp,-MD,depsfile"
def runtest(self):
try:
@@ -1639,12 +1634,8 @@ class DashWpMD_Case(CompileHello_Case):
pass
self.compile()
deps = open('depsfile').read()
- self.assert_re_search(r"testhdr.h", deps);
- # The following assertion is commented out for now
- # because it does not pass in pump mode.
- # FIXME This is a real bug that we need to fix!
- # Pump mode is treating -MD as if it was -MMD.
- # self.assert_re_search(r"stdio.h", deps);
+ self.assert_re_search(r"testhdr\.h", deps)
+ self.assert_re_search(r"stdio\.h", deps)
class ScanIncludes_Case(CompileHello_Case):
"""Test --scan-includes"""
diff --git a/update-distcc-symlinks.py b/update-distcc-symlinks.py
index bc5cff2..71a5188 100755
--- a/update-distcc-symlinks.py
+++ b/update-distcc-symlinks.py
@@ -1,78 +1,89 @@
#!/usr/bin/env python3
-import subprocess, string, os, stat, re
+import subprocess
+import string
+import os
+import stat
+import re
-distcc_dir = "/usr/lib/distcc"
-gcc_dir = "/usr/lib/gcc"
-gcccross_dir = "/usr/lib/gcc-cross"
+distcc_dir = "@prefix@/lib/distcc"
+GCC_LIBEXEC_DIRS = (
+ '/usr/lib/gcc', # Debian native GCC compilers
+ '/usr/lib/gcc-cross', # Debian GCC cross-compilers
+ '/usr/libexec/gcc', # rpm-based distros
+)
old_symlinks = set()
new_symlinks = set()
standard_names = ["cc", "c++", "c89", "c99"]
if not os.access(distcc_dir, os.X_OK):
- os.mkdir(distcc_dir)
+ os.mkdir(distcc_dir)
+
def consider(name):
- if os.access("/usr/bin/%(name)s" % vars(), os.X_OK):
- new_symlinks.add(name)
- print(name)
+ if os.access(f"/usr/bin/{name}", os.X_OK):
+ new_symlinks.add(name)
+ print(name)
+
+
+def consider_gcc(prefix, suffix=""):
+ consider(f"{prefix}gcc{suffix}")
+ consider(f"{prefix}g++{suffix}")
-def consider_gcc(prefix, suffix):
- consider("%(prefix)sgcc%(suffix)s" % vars())
- consider("%(prefix)sg++%(suffix)s" % vars())
def consider_clang(suffix):
- consider("clang%(suffix)s" % vars())
- consider("clang++%(suffix)s" % vars())
+ consider(f"clang{suffix}")
+ consider(f"clang++{suffix}")
+
for x in standard_names:
- consider(x)
-
-consider_gcc("", "")
-consider_gcc("c89-", "")
-consider_gcc("c99-", "")
-try:
- for gnu_host in os.listdir(gcc_dir):
- consider_gcc("%(gnu_host)s-" % vars(), "")
- for version in os.listdir(gcc_dir + "/" + gnu_host):
- consider_gcc("", "-%(version)s" % vars())
- consider_gcc("%(gnu_host)s-" % vars(), "-%(version)s" % vars())
-except FileNotFoundError:
- pass
-except NotADirectoryError:
- pass
-try:
- for gnu_host in os.listdir(gcccross_dir):
- consider_gcc("%(gnu_host)s-" % vars(), "")
- for version in os.listdir(gcccross_dir + "/" + gnu_host):
- consider_gcc("", "-%(version)s" % vars())
- consider_gcc("%(gnu_host)s-" % vars(), "-%(version)s" % vars())
-except FileNotFoundError:
- pass
-except NotADirectoryError:
- pass
+ consider(x)
+
+consider_gcc("")
+consider_gcc("c89-")
+consider_gcc("c99-")
+
+
+def sloppy_listdir(thedir):
+ try:
+ return os.listdir(thedir)
+ except FileNotFoundError:
+ pass
+ except NotADirectoryError:
+ pass
+ return []
+
+
+def scan_gcc_libexec(gcc_dir):
+ for gnu_host in sloppy_listdir(gcc_dir):
+ consider_gcc(f"{gnu_host}-")
+ for version in sloppy_listdir(gcc_dir + "/" + gnu_host):
+ consider_gcc("", f"-{version}")
+ consider_gcc(f"{gnu_host}-", f"-{version}")
+
+
+for gcc_dir in GCC_LIBEXEC_DIRS:
+ scan_gcc_libexec(gcc_dir)
+
consider_clang("")
for ent in os.listdir("/usr/lib"):
- if ent.startswith("llvm-"):
- version = ent.split("-")[1]
- consider_clang("-%(version)s" % vars())
+ if ent.startswith("llvm-"):
+ version = ent.split("-")[1]
+ consider_clang(f"-{version}")
for name in os.listdir(distcc_dir):
- mode = os.lstat(distcc_dir + "/" + name).st_mode
- if stat.S_ISLNK(mode):
- if os.access(distcc_dir + "/" + name, os.X_OK):
- old_symlinks.add(name)
- else:
- os.unlink(distcc_dir + "/" + name)
+ mode = os.lstat(distcc_dir + "/" + name).st_mode
+ if stat.S_ISLNK(mode):
+ if os.access(distcc_dir + "/" + name, os.X_OK):
+ old_symlinks.add(name)
+ else:
+ os.unlink(distcc_dir + "/" + name)
for link in old_symlinks:
- if link not in new_symlinks:
- os.unlink(distcc_dir + "/" + link)
+ if link not in new_symlinks:
+ os.unlink(distcc_dir + "/" + link)
for link in new_symlinks:
- if link not in old_symlinks:
- if os.access("/usr/bin/distcc", os.X_OK):
- os.symlink("../../bin/distcc", distcc_dir + "/" + link)
- else:
- os.symlink("../../local/bin/distcc", distcc_dir + "/" + link)
+ if link not in old_symlinks:
+ os.symlink("../../bin/distcc", distcc_dir + "/" + link)