From owner-svn-src-all@freebsd.org Thu Oct 19 03:17:52 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21D3BE4D16B; Thu, 19 Oct 2017 03:17:52 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E932A75617; Thu, 19 Oct 2017 03:17:51 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9J3HpSJ000808; Thu, 19 Oct 2017 03:17:51 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9J3Ho8I000805; Thu, 19 Oct 2017 03:17:50 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201710190317.v9J3Ho8I000805@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Thu, 19 Oct 2017 03:17:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324738 - in head/etc: defaults periodic/daily rc.d X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in head/etc: defaults periodic/daily rc.d X-SVN-Commit-Revision: 324738 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Oct 2017 03:17:52 -0000 Author: cy Date: Thu Oct 19 03:17:50 2017 New Revision: 324738 URL: https://svnweb.freebsd.org/changeset/base/324738 Log: Anticongestion refinements for ntpd rc script. This reverts r324681 and checks if ntp leapfile needs fetching before entering into the anticongestion sleep. Unfortunately some ports still use their own sleeps so, this commit doesn't address the complete problem which is compounded by every port that uses its own anticongestion mechanism. Discussed with: asomers Modified: head/etc/defaults/periodic.conf head/etc/periodic/daily/480.leapfile-ntpd head/etc/rc.d/ntpd Modified: head/etc/defaults/periodic.conf ============================================================================== --- head/etc/defaults/periodic.conf Thu Oct 19 02:14:39 2017 (r324737) +++ head/etc/defaults/periodic.conf Thu Oct 19 03:17:50 2017 (r324738) @@ -141,8 +141,6 @@ daily_status_mail_rejects_shorten="NO" # Shorten out # 480.leapfile-ntpd daily_ntpd_leapfile_enable="YES" # Fetch NTP leapfile -daily_ntpd_leapfile_background="NO" # Fetch NTP leapfile - # in the background # 480.status-ntpd daily_status_ntpd_enable="NO" # Check NTP status Modified: head/etc/periodic/daily/480.leapfile-ntpd ============================================================================== --- head/etc/periodic/daily/480.leapfile-ntpd Thu Oct 19 02:14:39 2017 (r324737) +++ head/etc/periodic/daily/480.leapfile-ntpd Thu Oct 19 03:17:50 2017 (r324738) @@ -13,15 +13,10 @@ fi case "$daily_ntpd_leapfile_enable" in [Yy][Ee][Ss]) - case "$daily_ntpd_leapfile_background" in - [Yy][Ee][Ss]) - (anticongestion && service ntpd onefetch) & - ;; - *) + if service ntpd oneneedfetch; then anticongestion service ntpd onefetch - ;; - esac + fi ;; esac Modified: head/etc/rc.d/ntpd ============================================================================== --- head/etc/rc.d/ntpd Thu Oct 19 02:14:39 2017 (r324737) +++ head/etc/rc.d/ntpd Thu Oct 19 03:17:50 2017 (r324738) @@ -15,8 +15,9 @@ desc="Network Time Protocol daemon" rcvar="ntpd_enable" command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" -extra_commands="fetch" +extra_commands="fetch needfetch" fetch_cmd="ntpd_fetch_leapfile" +needfetch_cmd="ntpd_needfetch_leapfile" start_precmd="ntpd_precmd" load_rc_config $name @@ -90,7 +91,7 @@ ntpd_init_leapfile() { fi } -ntpd_fetch_leapfile() { +ntpd_needfetch_leapfile() { local ntp_tmp_leapfile rc verbose if checkyesno ntp_leapfile_fetch_verbose; then @@ -122,6 +123,21 @@ ntpd_fetch_leapfile() { ntp_leap_fetch_date=$((ntp_leap_expiry-ntp_leapfile_expiry_seconds)) if [ $(current_ntp_ts) -ge $ntp_leap_fetch_date ]; then $verbose Within ntp leapfile expiry limit, initiating fetch + # Return code 0: ntp leapfile fetch needed + return 0 + fi + # Return code 1: ntp leapfile fetch not needed + return 1 +} + +ntpd_fetch_leapfile() { + if checkyesno ntp_leapfile_fetch_verbose; then + verbose=echo + else + verbose=: + fi + + if ntpd_needfetch_leapfile ; then for url in $ntp_leapfile_sources ; do $verbose fetching $url fetch $ntp_leapfile_fetch_opts -o $ntp_tmp_leapfile $url && break