#798830 dmucs: race condition in start scripts prevents loadavg starting

Package:
dmucs
Source:
dmucs
Description:
distributed compilation system for use with distcc
Submitter:
Tim Connors
Date:
2015-09-13 11:24:06 UTC
Severity:
important
#798830#5
Date:
2015-09-13 11:20:59 UTC
From:
To:
I've been wondering for years why dmucs never worked in my network.
Finally traced the start scripts:

            if start_server && server_running ;  then
...
            if start_loadavg && running ;  then

start_server and start_loadavg don't create a valid PID file for some
indeterminate time after start-stop-daemon fork off a dmucs/loadavg
process.

+ log_daemon_msg 'Starting dmucs distcc coordinator ' dmucs
+ '[' -z 'Starting dmucs distcc coordinator ' ']'
+ log_daemon_msg_pre 'Starting dmucs distcc coordinator ' dmucs
+ log_use_fancy_output
+ TPUT=/usr/bin/tput
+ EXPR=/usr/bin/expr
+ '[' -t 1 ']'
+ '[' xxterm '!=' x ']'
+ '[' xxterm '!=' xdumb ']'
+ '[' -x /usr/bin/tput ']'
+ '[' -x /usr/bin/expr ']'
+ /usr/bin/tput hpa 60
+ /usr/bin/tput setaf 1
+ '[' -z ']'
+ FANCYTTY=1
+ case "$FANCYTTY" in
+ true
+ echo -n '[....] '
[....] + '[' -z dmucs ']'
+ echo -n 'Starting dmucs distcc coordinator : dmucs'
Starting dmucs distcc coordinator : dmucs+ log_daemon_msg_post 'Starting dmucs distcc coordinator ' dmucs
+ :
+ server_running
+ '[' '!' -f /var/run/dmucs.pid ']'
+ return 1
+ start_server
+ start-stop-daemon --background --make-pidfile --start --pidfile /var/run/dmucs.pid --exec /usr/sbin/dmucs --
+ errcode=0
+ return 0
+ server_running
+ '[' '!' -f /var/run/dmucs.pid ']'
+ return 1
+ log_end_msg 1

Bugger.  Bails out with failure message instead of continuuing on to
start loadavg.

A quick "fix" is to:

            if start_server && sleep 5 && server_running ;  then
...
            if start_loadavg && sleep 5 && running ;  then

but surely there's a better way (eg, remove the test entirely, since
I've never seen any other init script do something like this).