[pkg-ntp-maintainers] Bug#679051: ntp: Start of ntp during boot is delayed by 60 seconds at lockfile-touch step
Andy Smith
andy at strugglers.net
Tue Jun 26 01:11:42 UTC 2012
Package: ntp
Version: 1:4.2.6.p5+dfsg-2
Severity: minor
Dear Maintainer,
For a long while now (certainly through lenny and squeeze) I've noticed that on
boot of my Xen-based virtual machines, ntp seems to take an inordinately long
time to get started. I initially wrote this off as some peculiarity of Xen, as
ntp did start after about a minute and all seemed well.
I have just looked into it further by inserting a "set -x" in /etc/init.d/ntp
to see which part it was actually waiting on, and was surprised to find it was
lockfile-touch.
Here is a portion of the output of /etc/init.d/ntp up until the place where it
pauses:
+ /bin/echo -n Starting NTP server: ntpd
Starting NTP server: ntpd+ log_daemon_msg_post Starting NTP server ntpd
+ :
+ [ -z 101:104 ]
+ lock_ntpdate
+ [ -x /usr/bin/lockfile-create ]
+ lockfile-create /var/lock/ntpdate
At this point there is a pause of 60 seconds, and then:
+ LOCKTOUCHPID=1422
+ start-stop-daemon --start --quiet --oknodo --pidfile /var/run/ntpd.pid --startas /usr/sbin/ntpd -- -p /var/run/ntpd.pid -x -g -u 101:104
+ lockfile-touch /var/lock/ntpdate
+ status=0
+ unlock_ntpdate
+ [ -x /usr/bin/lockfile-create ]
+ kill 1422
+ lockfile-remove /var/lock/ntpdate
+ log_end_msg 0
...and so on.
In /etc/init.d/ntp there's this:
lock_ntpdate() {
if [ -x /usr/bin/lockfile-create ]; then
lockfile-create $LOCKFILE
lockfile-touch $LOCKFILE &
LOCKTOUCHPID="$!"
fi
}
I don't understand why, but it seems like the lockfile-touch part is waiting
for 60 seconds even though it's invoked with "&".
Subsequent stop/start of the daemon with invoke-rc.d after boot don't have any
such pause.
This VM, though running wheezy, is based on an image that was initially running
sarge and has been dist-upgraded through all releases over the years. I haven't
yet tested whether the same thing happens on a clean install of wheezy in the
same environment.
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 3.2.0-2-686-pae (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages ntp depends on:
ii adduser 3.113+nmu3
ii dpkg 1.16.3
ii libc6 2.13-33
ii libcap2 1:2.22-1
ii libedit2 2.11-20080614-5
ii libopts25 1:5.12-0.1
ii libssl1.0.0 1.0.1c-3
ii lsb-base 4.1+Debian6
ii netbase 5.0
Versions of packages ntp recommends:
ii perl 5.14.2-12
Versions of packages ntp suggests:
pn ntp-doc <none>
-- Configuration Files:
/etc/default/ntp changed:
NTPD_OPTS='-x -g'
/etc/init.d/ntp changed:
set -x
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions
DAEMON=/usr/sbin/ntpd
PIDFILE=/var/run/ntpd.pid
test -x $DAEMON || exit 5
if [ -r /etc/default/ntp ]; then
. /etc/default/ntp
fi
if [ -e /var/lib/ntp/ntp.conf.dhcp ]; then
NTPD_OPTS="$NTPD_OPTS -c /var/lib/ntp/ntp.conf.dhcp"
fi
LOCKFILE=/var/lock/ntpdate
lock_ntpdate() {
if [ -x /usr/bin/lockfile-create ]; then
lockfile-create $LOCKFILE
lockfile-touch $LOCKFILE &
LOCKTOUCHPID="$!"
fi
}
unlock_ntpdate() {
if [ -x /usr/bin/lockfile-create ] ; then
kill $LOCKTOUCHPID
lockfile-remove $LOCKFILE
fi
}
RUNASUSER=ntp
UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true
if test "$(uname -s)" = "Linux"; then
NTPD_OPTS="$NTPD_OPTS -u $UGID"
fi
case $1 in
start)
log_daemon_msg "Starting NTP server" "ntpd"
if [ -z "$UGID" ]; then
log_failure_msg "user \"$RUNASUSER\" does not exist"
exit 1
fi
lock_ntpdate
start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -p $PIDFILE $NTPD_OPTS
status=$?
unlock_ntpdate
log_end_msg $status
;;
stop)
log_daemon_msg "Stopping NTP server" "ntpd"
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
log_end_msg $?
rm -f $PIDFILE
;;
restart|force-reload)
$0 stop && sleep 2 && $0 start
;;
try-restart)
if $0 status >/dev/null; then
$0 restart
else
exit 0
fi
;;
reload)
exit 3
;;
status)
status_of_proc $DAEMON "NTP server"
;;
*)
echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
exit 2
;;
esac
-- no debconf information
More information about the pkg-ntp-maintainers
mailing list