diff -Nadur distcc-2.16/Makefile.in distcc-2.16-slp/Makefile.in --- distcc-2.16/Makefile.in 2004-07-06 08:08:50.000000000 +0000 +++ distcc-2.16-slp/Makefile.in 2005-02-05 19:00:57.693819041 +0000 @@ -62,7 +62,7 @@ GNOME_CFLAGS = @GNOME_CFLAGS@ GNOME_LIBS = @GNOME_LIBS@ -LIBS = @LIBS@ +LIBS = @LIBS@ @LIB_SLP@ DESTDIR = @@ -84,6 +84,7 @@ $(MEN) \ $(pkgdoc_DOCS) \ $(example_DOCS) \ + $(slp_EXTRA) $(slp_SRC) $(slp_HEADERS) \ $(popt_EXTRA) $(popt_SRC) $(popt_HEADERS) \ $(SRC) $(HEADERS) \ $(test_SOURCE) \ @@ -176,6 +177,8 @@ src/safeguard.o src/snprintf.o src/timeval.o \ lzo/minilzo.o +distccenv_obj = src/distccenv.o src/cc_version.o + distcc_obj = src/backoff.o \ src/climasq.o src/clinet.o src/clirpc.o \ src/compile.o src/cpp.o \ @@ -193,7 +196,7 @@ src/ncpus.o \ src/prefork.o \ src/serve.o src/setuid.o src/srvnet.o src/srvrpc.o \ - $(common_obj) @BUILD_POPT@ + $(common_obj) @BUILD_POPT@ @BUILD_SLP@ # Objects that need to be linked in to build monitors mon_obj = \ @@ -227,7 +230,7 @@ src/cleanup.c \ src/climasq.c src/clinet.c src/clirpc.c src/compile.c \ src/compress.c src/cpp.c \ - src/daemon.c src/distcc.c src/dsignal.c \ + src/daemon.c src/distcc.c src/dsignal.c src/register_slp.c \ src/dopt.c src/dparent.c src/exec.c src/filename.c \ src/h_argvtostr.c \ src/h_exten.c src/h_hosts.c src/h_issource.c src/h_parsemask.c \ @@ -270,6 +273,11 @@ gnome_data = gnome/distccmon-gnome-icon.png \ gnome/distccmon-gnome.desktop +slp_OBJS=src/register_slp.o src/cc_version.o +slp_SRC=src/register_slp.c src/cc_version.c +slp_HEADERS = src/register_slp.h src/cc_version.h +slp_EXTRA = README.slp + popt_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \ popt/popthelp.o popt/poptparse.o @@ -297,7 +305,8 @@ distcc@EXEEXT@ \ distccd@EXEEXT@ \ distccmon-text@EXEEXT@ \ - @GNOME_BIN@ + @GNOME_BIN@ \ + @SLP_BIN@ check_PROGRAMS = \ h_argvtostr@EXEEXT@ \ @@ -339,6 +348,9 @@ distcc@EXEEXT@: $(distcc_obj) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(distcc_obj) $(LIBS) +distccenv@EXEEXT@: $(distccenv_obj) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(distccenv_obj) $(LIBS) + distccd@EXEEXT@: $(distccd_obj) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(distccd_obj) $(LIBS) diff -Nadur distcc-2.16/README.slp distcc-2.16-slp/README.slp --- distcc-2.16/README.slp 1970-01-01 00:00:00.000000000 +0000 +++ distcc-2.16-slp/README.slp 2005-02-05 19:00:57.693819041 +0000 @@ -0,0 +1,40 @@ +# +# SLP support in distcc +# + +It is enough to start the SLP server and distcc server, if you have +compiled distccd with SLP support. You can simply use distcc as compiler +afterwards. + +NOTE: SLP support is only used, when distccd runs as daemon, not when + running via inetd or xinetd ! + +The distcc frontend cache SLP results inside the $HOME/.distcc.slp.cache +file. This file gets update every 3 minutes (hardcoded for now). + +Alternative you can set the enviroment once via distccenv. A bash user +might simply do to set $DISTCC_HOSTS with + + eval `distccenv` + +A distcc service url looks like + + service:distccd.$IDENTITY + +The identity is usually set based on the used compiler at build time +of distcc and the used system architecture. +However there is no check which checks the installed compiler, since it +is not known how it is called at distccd startup time. + +You can set the IDENTITY during distccd startup via the --slp-identy=$IDENTITY +switch. You need to set the $DISTCC_IDENTITY enviroment variable to the +same value afterwards inside your enviroment (or during distccenv run). + +There is some very basic load balancing code. You can enable it via + + export DISTCC_LOAD_BALANCE=1 + +in your compile enviroment. It is not active, if $DISTCC_HOSTS is set. + +Have fun, adrian. + diff -Nadur distcc-2.16/configure distcc-2.16-slp/configure --- distcc-2.16/configure 2004-07-08 04:59:02.000000000 +0000 +++ distcc-2.16-slp/configure 2005-02-05 19:00:57.700818024 +0000 @@ -310,7 +310,7 @@ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os docdir CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT GNOME_PACKAGES GNOME_CFLAGS GNOME_LIBS INSTALL_GNOME SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PYTHON CPP EGREP BUILD_POPT GNOME_BIN LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os docdir CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT GNOME_PACKAGES GNOME_CFLAGS GNOME_LIBS INSTALL_GNOME SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PYTHON CPP EGREP LIB_SLP BUILD_POPT GNOME_BIN SLP_BIN BUILD_SLP LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -853,6 +853,7 @@ --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-rfc2553 use getaddrinfo, getnameinfo, etc --enable-profile turn on gprof + --enable-slp find hosts via slp Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -965,7 +966,7 @@ else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd "$ac_popdir" + cd $ac_popdir done fi @@ -2000,7 +2001,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2058,7 +2060,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2174,7 +2177,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2228,7 +2232,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2273,7 +2278,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2317,7 +2323,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2391,7 +2398,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2461,7 +2469,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2526,7 +2535,6 @@ fi; - # Check whether --with-gnome or --without-gnome was given. if test "${with_gnome+set}" = set; then withval="$with_gnome" @@ -2990,7 +2998,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3048,7 +3057,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3164,7 +3174,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3218,7 +3229,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3263,7 +3275,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3307,7 +3320,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3393,7 +3407,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3447,7 +3462,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3680,7 +3696,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4010,7 +4027,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4180,7 +4198,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4250,7 +4269,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4402,7 +4422,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4548,7 +4569,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4611,7 +4633,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4680,7 +4703,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4751,7 +4775,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4915,7 +4940,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4992,7 +5018,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5069,7 +5096,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5151,7 +5179,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5205,7 +5234,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5275,7 +5305,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5329,7 +5360,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5399,7 +5431,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5453,7 +5486,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5523,7 +5557,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5577,7 +5612,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5645,7 +5681,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5829,6 +5866,95 @@ echo "${ECHO_T}no" >&6 fi +######################################################################## +# Check for OpenSLP +# Check whether --enable-slp or --disable-slp was given. +if test "${enable_slp+set}" = set; then + enableval="$enable_slp" + with_slp=$enableval +else + with_slp=no +fi; +if test "$with_slp" = "yes"; then +echo "$as_me:$LINENO: checking for SLP support" >&5 +echo $ECHO_N "checking for SLP support... $ECHO_C" >&6 +save_slptest_LIBS="$LIBS" +save_slptest_LDFLAGS="$LDFLAGS" +save_slptest_CPPFLAGS="$CPPFLAGS" +LDFLAGS="$all_libraries $LDFLAGS" +CPPFLAGS="$CPPFLAGS $all_includes" +LIBS="-lslp" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + +int +main () +{ + + SLPOpen(0, SLP_FALSE, (SLPHandle*) 0); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + +cat >>confdefs.h <<\_ACEOF +#define WITH_SLP 1 +_ACEOF + + LIB_SLP="-lslp" + SLP_BIN=distccenv + BUILD_SLP='$(slp_OBJS)' + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + { { echo "$as_me:$LINENO: error: no" >&5 +echo "$as_me: error: no" >&2;} + { (exit 1); exit 1; }; } + +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +CPPFLAGS=$save_slptest_CPPFLAGS +LDFLAGS=$save_slptest_LDFLAGS +LIBS=$save_slptest_LIBS +fi + + ######################################################################## @@ -5872,7 +5998,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -5902,7 +6029,6 @@ - ######################################################################## # Checks for library functions, using libraries discovered above CPPFLAGS="$CPPFLAGS -I$srcdir/src" @@ -5983,7 +6109,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6091,7 +6218,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6197,7 +6325,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6300,7 +6429,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6404,7 +6534,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6507,7 +6638,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6572,7 +6704,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6641,7 +6774,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6710,7 +6844,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6779,7 +6914,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6848,7 +6984,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6923,7 +7060,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -6979,7 +7117,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7038,7 +7177,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7228,7 +7368,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7272,7 +7413,8 @@ cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -7313,6 +7455,8 @@ + + cat >>confdefs.h <<_ACEOF #define GNU_HOST "$host" _ACEOF @@ -7958,8 +8102,11 @@ s,@PYTHON@,$PYTHON,;t t s,@CPP@,$CPP,;t t s,@EGREP@,$EGREP,;t t +s,@LIB_SLP@,$LIB_SLP,;t t s,@BUILD_POPT@,$BUILD_POPT,;t t s,@GNOME_BIN@,$GNOME_BIN,;t t +s,@SLP_BIN@,$SLP_BIN,;t t +s,@BUILD_SLP@,$BUILD_SLP,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF @@ -8128,6 +8275,11 @@ *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ @@ -8166,12 +8318,6 @@ fi;; esac done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub diff -Nadur distcc-2.16/configure.ac distcc-2.16-slp/configure.ac --- distcc-2.16/configure.ac 2004-07-08 04:55:59.000000000 +0000 +++ distcc-2.16-slp/configure.ac 2005-02-05 19:00:57.700818024 +0000 @@ -89,7 +89,6 @@ AC_HELP_STRING([--enable-rfc2553], [use getaddrinfo, getnameinfo, etc]), AC_DEFINE(ENABLE_RFC2553,1,[Use getaddrinfo(), getnameinfo(), etc])) - AC_ARG_WITH(gnome, AC_HELP_STRING([--with-gnome], [build GNOME-based monitor])) @@ -283,13 +282,42 @@ AC_MSG_RESULT(no) fi +######################################################################## +# Check for OpenSLP +AC_ARG_ENABLE(slp, [ --enable-slp find hosts via slp], with_slp=$enableval, with_slp=no) +if test "$with_slp" = "yes"; then +AC_MSG_CHECKING(for SLP support) +save_slptest_LIBS="$LIBS" +save_slptest_LDFLAGS="$LDFLAGS" +save_slptest_CPPFLAGS="$CPPFLAGS" +LDFLAGS="$all_libraries $LDFLAGS" +CPPFLAGS="$CPPFLAGS $all_includes" +LIBS="-lslp" +AC_TRY_LINK( [ + #include + ],[ + SLPOpen(0, SLP_FALSE, (SLPHandle*) 0); + ],[ + AC_DEFINE(WITH_SLP,1,[Define if SLP is avaible and enabled]) + LIB_SLP="-lslp" + SLP_BIN=distccenv + BUILD_SLP='$(slp_OBJS)' + AC_MSG_RESULT(yes) + ],[ + AC_MSG_ERROR(no) +]) +CPPFLAGS=$save_slptest_CPPFLAGS +LDFLAGS=$save_slptest_LDFLAGS +LIBS=$save_slptest_LIBS +fi +AC_SUBST(LIB_SLP) + ######################################################################## # Check for types AC_TYPE_SIGNAL - ######################################################################## # Checks for library functions, using libraries discovered above CPPFLAGS="$CPPFLAGS -I$srcdir/src" @@ -390,6 +418,8 @@ AC_SUBST(CPPFLAGS) AC_SUBST(BUILD_POPT) AC_SUBST(GNOME_BIN) +AC_SUBST(SLP_BIN) +AC_SUBST(BUILD_SLP) dnl AC_DEFINE_UNQUOTED(PACKAGE, $PACKAGE, [Package name]) dnl AC_DEFINE_UNQUOTED(VERSION, $VERSION, [Package version]) AC_DEFINE_UNQUOTED(GNU_HOST, ["$host"], [Your gnu-style host triple]) diff -Nadur distcc-2.16/src/cc_version.c distcc-2.16-slp/src/cc_version.c --- distcc-2.16/src/cc_version.c 1970-01-01 00:00:00.000000000 +0000 +++ distcc-2.16-slp/src/cc_version.c 2005-02-05 19:00:57.701817879 +0000 @@ -0,0 +1,93 @@ +/* -*- c-file-style: "java"; indent-tabs-mode: nil -*- + * + * distcc -- A simple distributed compiler system + * + * Copyright (C) 2003 by Adrian Schroeter + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#include +#include +#include +#include +#include "cc_version.h" +#include "config.h" + +char *used_compiler_version(void) +{ + char *compiler = NULL; + char *architecture = NULL; + char *ret; + int len; + + /* The enviroment is always right ... */ + if ( getenv("DISTCC_IDENTIFY") ) + return getenv("DISTCC_IDENTIFY"); + + /* do we really want a runtime check here ? */ + /* it would be worse performance wise for the distcc frontend ... */ + + /* default compiler based on distcc build time */ +#ifdef __GNUC__ +#ifdef __GNUC_MINOR__ +#ifdef __GNUC_PATCHLEVEL__ + compiler = (char*) malloc( 33 ); + snprintf( compiler, 32, "gcc-%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ ); +#endif +#endif +#endif + +#ifdef GNU_HOST + architecture = strdup(GNU_HOST); + { + char *p; + p = strstr( architecture, "-" ); + if (p){ + *p = '\0'; + /* unify all different ia32 systems */ + p = architecture; + if ( p[0] == 'i' && p[2] == '8' && p[3] == '6' && p[4] == '\0' ) + p[1] = '3'; + } + } +#endif + + if ( compiler == NULL ){ + /* we use the system release, this is unreleated to the compiler + version, but better than default ... */ + struct utsname t; + if ( !uname( &t ) ) + compiler = t.release; + } + if ( architecture == NULL ){ + struct utsname t; + if ( !uname( &t ) ) + architecture = t.machine; + } + + /* fallback values */ + if ( compiler == NULL ) + compiler = strdup("default"); + if ( architecture == NULL ) + architecture = strdup("default"); + + len = strlen(compiler) + 1 + strlen(architecture) + 1; + ret = (char*) malloc(len + 1); + snprintf( ret, len, "%s-%s", compiler, architecture ); + return ret; +} + diff -Nadur distcc-2.16/src/cc_version.h distcc-2.16-slp/src/cc_version.h --- distcc-2.16/src/cc_version.h 1970-01-01 00:00:00.000000000 +0000 +++ distcc-2.16-slp/src/cc_version.h 2005-02-05 19:00:57.701817879 +0000 @@ -0,0 +1,3 @@ + +char *used_compiler_version(void); + diff -Nadur distcc-2.16/src/config.h.in distcc-2.16-slp/src/config.h.in --- distcc-2.16/src/config.h.in 2004-07-07 01:55:40.000000000 +0000 +++ distcc-2.16-slp/src/config.h.in 2005-02-05 19:00:57.701817879 +0000 @@ -242,6 +242,9 @@ /* Use GTK+ */ #undef WITH_GTK +/* Use SLP */ +#undef WITH_SLP + /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus diff -Nadur distcc-2.16/src/distccenv.c distcc-2.16-slp/src/distccenv.c --- distcc-2.16/src/distccenv.c 1970-01-01 00:00:00.000000000 +0000 +++ distcc-2.16-slp/src/distccenv.c 2005-02-05 19:00:57.701817879 +0000 @@ -0,0 +1,205 @@ + +#include "config.h" + +#ifndef WITH_SLP +#error distccenv needs SLP atm. +#endif + +#include +#include +#include + +#include "register_slp.h" + +#define BUFFER 1024 + +char compiler[BUFFER + 1]; +FILE *out; + +#define MAX_HOSTS 256 +struct dcc_host{ + char *url; + int jobs; + float speed; + float load; + long value; +}; +struct dcc_host hosts[MAX_HOSTS]; +int host_count = 0; + +int slp_calls = 0; +int load_balancing = 0; + +void dump_result(void); +SLPBoolean myAttrCallback(SLPHandle phslp, char* attrlist, + SLPError errcode, void* cookie ); +SLPBoolean MySLPSrvURLCallback( SLPHandle phslp, const char* srvurl, + unsigned short lifetime, SLPError errcode, + void* cookie ); + +void dump_result(void) +{ + int h, j, max_jobs = 0; + float avg_speed = 0, avg_load = 0; + + if ( host_count == 0 ) + exit(-1); + + if ( !out ) + printf( "DISTCC_HOSTS=\"" ); + + if ( load_balancing ) + { + for ( h = 0; h 2 && !strcmp(argv[1], "--file" ) ) + out = fopen( argv[2], "w" ); + + snprintf( compiler, BUFFER, "service:distccd.%s", used_compiler_version() ); + + result = SLPOpen( NULL, SLP_FALSE, &phslp); + if (result != SLP_OK) { + fprintf( stderr, "SLPOpen failed ! Aborting ... " ); + exit( -1 ); + } else { + result = SLPFindSrvs( phslp, + compiler, + "", // TODO: Scope selector + "", // all services + MySLPSrvURLCallback, + 0 ); + if (result != SLP_OK){ + fprintf( stderr, "unable to query for services ! Aborting .." ); + exit(-1); + } + + if ( load_balancing ) + { + for ( h = 0; h < host_count; h++ ) + { + char buf[BUFFER+1]; + snprintf( buf, BUFFER, "%s://%s", compiler, hosts[h].url ); + result = SLPFindAttrs(phslp, + buf, + "", + "maxjobs,bogomips,load", + myAttrCallback, + (void*)h); + if(result != SLP_OK) + { + printf("unable to request SLP attributes: %i\n",result); + exit(-1); + } + } + }else + dump_result(); + + SLPClose( phslp ); + } + + dump_result(); + return 0; +} diff -Nadur distcc-2.16/src/dopt.c distcc-2.16-slp/src/dopt.c --- distcc-2.16/src/dopt.c 2004-07-07 04:43:45.000000000 +0000 +++ distcc-2.16-slp/src/dopt.c 2005-02-05 19:00:57.702817734 +0000 @@ -50,6 +50,10 @@ #include "setuid.h" #include "access.h" +#ifdef WITH_SLP +#include "register_slp.h" +#endif + int opt_niceness = 5; /* default */ /** @@ -90,6 +94,7 @@ const char *arg_pid_file = NULL; const char *arg_log_file = NULL; +const char *compiler_version = NULL; /* Enumeration values for options that don't have single-letter name. These * must be numerically above all the ascii letters. */ @@ -120,6 +125,9 @@ { "verbose", 0, POPT_ARG_NONE, 0, 'v', 0, 0 }, { "version", 0, POPT_ARG_NONE, 0, 'V', 0, 0 }, { "wizard", 'W', POPT_ARG_NONE, 0, 'W', 0, 0 }, +#ifdef WITH_SLP + { "slp-identy", 0, POPT_ARG_STRING, &compiler_version, 0, 0, 0 }, +#endif { 0, 0, 0, 0, 0, 0, 0 } }; @@ -153,6 +161,10 @@ " Mode of operation:\n" " --inetd serve client connected to stdin\n" " --daemon bind and listen on socket\n" +#ifdef WITH_SLP +" SLP Identification:\n" +" --slp-identy=STRING to identify the provided compiler\n" +#endif "\n" "distccd runs either from inetd or as a standalone daemon to compile\n" "files submitted by the distcc client.\n" @@ -249,6 +261,11 @@ } } +#ifdef WITH_SLP + if ( compiler_version == NULL ) + compiler_version = used_compiler_version(); +#endif + poptFreeContext(po); return 0; diff -Nadur distcc-2.16/src/dopt.h distcc-2.16-slp/src/dopt.h --- distcc-2.16/src/dopt.h 2004-05-03 00:37:10.000000000 +0000 +++ distcc-2.16-slp/src/dopt.h 2005-02-05 19:00:57.702817734 +0000 @@ -20,6 +20,7 @@ * USA */ +#include "config.h" /* dopt.c */ extern struct dcc_allow_list *opt_allowed; @@ -38,3 +39,6 @@ extern int opt_lifetime; extern char *opt_listen_addr; extern int opt_niceness; +#ifdef WITH_SLP +extern const char *compiler_version; +#endif diff -Nadur distcc-2.16/src/dparent.c distcc-2.16-slp/src/dparent.c --- distcc-2.16/src/dparent.c 2004-07-07 02:12:27.000000000 +0000 +++ distcc-2.16-slp/src/dparent.c 2005-02-05 19:00:57.702817734 +0000 @@ -71,6 +71,9 @@ #include "types.h" #include "daemon.h" #include "netutil.h" +#if WITH_SLP +#include "register_slp.h" +#endif static void dcc_nofork_parent(int listen_fd) NORETURN; static void dcc_detach(void); @@ -136,6 +139,10 @@ * not. */ dcc_master_pid = getpid(); +#ifdef WITH_SLP + register_slp(); +#endif + if (opt_no_fork) { dcc_log_daemon_started("non-forking daemon"); dcc_nofork_parent(listen_fd); diff -Nadur distcc-2.16/src/hosts.c distcc-2.16-slp/src/hosts.c --- distcc-2.16/src/hosts.c 2004-07-06 08:08:14.000000000 +0000 +++ distcc-2.16-slp/src/hosts.c 2005-02-05 19:03:44.683565471 +0000 @@ -85,6 +85,8 @@ #include #include #include +#include +#include #include #include #include @@ -163,7 +165,33 @@ rs_trace("not reading %s: %s", path, strerror(errno)); free(path); } + +#ifdef WITH_SLP + char *home; + + if ((home = getenv("HOME")) != NULL) { + struct stat fst; + + asprintf(&path, "%s/.distcc.slp.cache", home); + /* the refresh rate of SLP cache is hardcoded to 5 minutes for now */ + if ( stat (path, &fst) || fst.st_mtime < time (0) - 60*5 ) { + unlink( path ); + /* sure, we could implement the SLP query also via a function + call, but we would need to wait here anyway ... */ + execlp("distccenv", "distccenv", "--file", path, 0 ); + } + if (access(path, R_OK) == 0) { + ret = dcc_parse_hosts_file(path, ret_list, ret_nhosts); + free(path); + return ret; + } else { + rs_trace("not reading %s: %s", path, strerror(errno)); + free(path); + } + } +#endif + /* FIXME: Clearer message? */ rs_log_warning("no hostlist is set; can't distribute work"); diff -Nadur distcc-2.16/src/register_slp.c distcc-2.16-slp/src/register_slp.c --- distcc-2.16/src/register_slp.c 1970-01-01 00:00:00.000000000 +0000 +++ distcc-2.16-slp/src/register_slp.c 2005-02-05 19:00:57.705817298 +0000 @@ -0,0 +1,127 @@ +/* -*- c-file-style: "java"; indent-tabs-mode: nil -*- + * + * distcc -- A simple distributed compiler system + * + * Copyright (C) 2003 by Adrian Schroeter + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#include "register_slp.h" + +#ifdef WITH_SLP +#include +#include +#include +#include +#include +#include +#include "dopt.h" +#include "trace.h" +#include "cc_version.h" + +extern int dcc_max_kids; + +void mySLPRegReport(SLPHandle hslp, SLPError errcode, void *cookie) +{ + hslp = hslp; cookie = cookie; + if (errcode) + rs_log_warning( "SLP (de)registration error" ); +} + +void refresh_slp(void) +{ + register_slp(); +} + +void register_slp(void) +{ + SLPHandle phslp; + SLPError result; + struct sigaction act, oact; + /* TODO: make it a config option */ + /* hardcode it to 5 minutes now, because we use also the load + from last 5 minutes */ + int slp_timeout = 60 * 3; + + /* do not bomb the slp server with wrong configuration */ + if ( slp_timeout < 120 ) + slp_timeout = 120 ; + if ( slp_timeout > SLP_LIFETIME_MAXIMUM ) + slp_timeout = SLP_LIFETIME_MAXIMUM; + + result = SLPOpen( 0, SLP_FALSE, &phslp); + if (result != SLP_OK) + rs_log_warning( "SLPOpen failed" ); + else { + char hostname[1024]; + char SLPServiceUrl[2048]; + char SLPattributes[2048]; + long load = -1, bogomips = 0; + FILE *proc; + + gethostname( hostname, 1023 ); + /* Linux specific part, no idea how to do this in general */ + proc = fopen( "/proc/cpuinfo", "r" ); + if ( proc ){ + while( !feof(proc) ) { + long b = 0; + int ret; + ret = fscanf( proc, "bogomips : %ld", &b ); + if ( ret < 0 ) + break; + if ( ret ) + bogomips += b; + fseek( proc, 1L, SEEK_CUR ); + } + fclose( proc ); + } + + proc = fopen( "/proc/loadavg", "r" ); + if ( proc ){ + fscanf( proc, "%*d.%*d %ld.%*d %*s %*s %*s", &load ); + fclose( proc ); + } + if ( !bogomips ) bogomips = 1; + load += 1; + + snprintf( SLPServiceUrl, 1023, "service:distccd.%s://%s:%i", compiler_version, hostname, arg_port ); + snprintf( SLPattributes, 1023, "(maxjobs=%d),(bogomips=%ld),(load=%ld)", dcc_max_kids, bogomips, load ); + + result = SLPReg( phslp, + SLPServiceUrl, + slp_timeout, + 0, + SLPattributes, + SLP_TRUE, + mySLPRegReport, + 0 ); + + if (result != SLP_OK) + rs_log_warning( "unable to register SLP service" ); + SLPClose( phslp ); + + /* sigalarm is also used in inetd mode, but we should never + use SLP in inetd mode anyway ... */ + act.sa_handler = refresh_slp; + if (0 != sigaction(SIGALRM, &act, &oact)) + rs_log_warning("Error establishing signal handler for SLP"); + alarm(slp_timeout - 15); + } +} +#endif + + diff -Nadur distcc-2.16/src/register_slp.h distcc-2.16-slp/src/register_slp.h --- distcc-2.16/src/register_slp.h 1970-01-01 00:00:00.000000000 +0000 +++ distcc-2.16-slp/src/register_slp.h 2005-02-05 19:00:57.705817298 +0000 @@ -0,0 +1,15 @@ + +#include "config.h" + +#ifdef WITH_SLP + +#include + +void register_slp(void); +char* used_compiler_version(void); + +void refresh_slp(void); +void mySLPRegReport(SLPHandle hslp, SLPError errcode, void *cookie); + +#endif +