From owner-svn-src-head@FreeBSD.ORG Thu Jan 29 06:41:13 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 715F7106564A; Thu, 29 Jan 2009 06:41:13 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id D12F08FC17; Thu, 29 Jan 2009 06:41:12 +0000 (UTC) (envelope-from keramida@freebsd.org) Received: from kobe.laptop (adsl7-92.kln.forthnet.gr [77.49.134.92]) (authenticated bits=128) by igloo.linux.gr (8.14.3/8.14.3/Debian-5) with ESMTP id n0T6f2LN016423 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 29 Jan 2009 08:41:08 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.3/8.14.3) with ESMTP id n0T6f24V036915; Thu, 29 Jan 2009 08:41:02 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from keramida@localhost) by kobe.laptop (8.14.3/8.14.3/Submit) id n0T6f1Ht036914; Thu, 29 Jan 2009 08:41:01 +0200 (EET) (envelope-from keramida@freebsd.org) From: Giorgos Keramidas To: Rong-en Fan References: <200901272013.n0RKDOBR095434@svn.freebsd.org> <6eb82e0901272050l6678ea37idc8ea53e948a15e5@mail.gmail.com> <87r62nnb7t.fsf@kobe.laptop> <6eb82e0901282128o1e38724bsc2dd7a44ebb7de1e@mail.gmail.com> Date: Thu, 29 Jan 2009 08:41:01 +0200 In-Reply-To: <6eb82e0901282128o1e38724bsc2dd7a44ebb7de1e@mail.gmail.com> (Rong-en Fan's message of "Thu, 29 Jan 2009 13:28:39 +0800") Message-ID: <87hc3i8via.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-MailScanner-ID: n0T6f2LN016423 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-4.509, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL -0.11, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@freebsd.org X-Spam-Status: No Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r187782 - in head: etc/rc.d share/man/man5 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2009 06:41:14 -0000 On Thu, 29 Jan 2009 13:28:39 +0800, Rong-en Fan wrote: >>> Shouldn't we keep ntp running after the clock is adjusted? >> >> This is correct too. The effect of `ntpd_sync_on_start' is supposed to >> be the same as if we run `ntpdate' before the real ntpd starts, so this >> option only applies to the first sync-once instance of ntpd. The real >> ntpd starts later, and finds the clock pre-synced. > > Hmm... I think I'm confused. According to rc.d/ntpd, if ntpd_sync_on_start > is set to yes, it adds '-q -g' to rc_flags. By doing so, ntpd start makes > ntpd exists immediately after the first sync. Then, who is responsible > to start the "real ntpd" you said above? Oops, testing with ntpd_sync_on_start again I think I broke rc.d/ntpd. I thought precmd was run in _addition_ to the start rc command, but it only runs before it and affects the flags of start too. I think I'll back out the change until we the sync on start for real. The folowing seems to work much better, but it shows a duplicate message about `Starting ntpd.' so I have reverted the broken change until I've worked through the patch a bit more: %%% diff -r 0c625c73ecc0 etc/rc.d/ntpd --- a/etc/rc.d/ntpd Wed Jan 28 18:38:39 2009 +0200 +++ b/etc/rc.d/ntpd Thu Jan 29 08:40:43 2009 +0200 @@ -8,29 +8,48 @@ # BEFORE: LOGIN # KEYWORD: nojail shutdown . /etc/rc.subr name=ntpd rcvar=`set_rcvar` command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" start_precmd="ntpd_precmd" +sync_cmd="ntpd_sync" +extra_commands="sync" load_rc_config $name +ntpd_sync() +{ + rc_flags="-c ${ntpd_config} ${ntpd_flags}" + + # Emulate ntpdate by running once and disabling threshold checks. + local _rc_flags_save="${rc_flags}" + local _sync_on_start="${ntpd_sync_on_start}" + + rc_flags="-q -g $rc_flags" + ntpd_sync_on_start="NO" # Avoid recursion in the next `start' + + run_rc_command start + + rc_flags="${_rc_flags_save}" + ntpd_sync_on_start="${_sync_on_start}" +} + ntpd_precmd() { rc_flags="-c ${ntpd_config} ${ntpd_flags}" if checkyesno ntpd_sync_on_start; then - rc_flags="-q -g $rc_flags" + run_rc_command sync fi if [ -z "$ntpd_chrootdir" ]; then return 0; fi # If running in a chroot cage, ensure that the appropriate files # exist inside the cage, as well as helper symlinks into the cage # from outside. # %%%