From owner-svn-src-all@freebsd.org Thu Nov 17 15:10:53 2016 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 AE5A0C4570F; Thu, 17 Nov 2016 15:10:53 +0000 (UTC) (envelope-from avg@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 54B3D1DD9; Thu, 17 Nov 2016 15:10:53 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uAHFAqda070464; Thu, 17 Nov 2016 15:10:52 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uAHFAqA5070463; Thu, 17 Nov 2016 15:10:52 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201611171510.uAHFAqA5070463@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 17 Nov 2016 15:10:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r308754 - stable/11/usr.sbin/watchdogd X-SVN-Group: stable-11 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, 17 Nov 2016 15:10:53 -0000 Author: avg Date: Thu Nov 17 15:10:52 2016 New Revision: 308754 URL: https://svnweb.freebsd.org/changeset/base/308754 Log: MFC r308040,308479: nap time between pats is forced to be at most half of the timeout Modified: stable/11/usr.sbin/watchdogd/watchdogd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/watchdogd/watchdogd.c ============================================================================== --- stable/11/usr.sbin/watchdogd/watchdogd.c Thu Nov 17 15:10:33 2016 (r308753) +++ stable/11/usr.sbin/watchdogd/watchdogd.c Thu Nov 17 15:10:52 2016 (r308754) @@ -80,7 +80,8 @@ static u_int timeout = WD_TO_128SEC; static u_int exit_timeout = WD_TO_NEVER; static u_int pretimeout = 0; static u_int timeout_sec; -static u_int passive = 0; +static u_int nap = 10; +static int passive = 0; static int is_daemon = 0; static int is_dry_run = 0; /* do not arm the watchdog, only report on timing of the watch @@ -88,7 +89,6 @@ static int is_dry_run = 0; /* do not ar static int do_timedog = 0; static int do_syslog = 1; static int fd = -1; -static int nap = 10; static int carp_thresh_seconds = -1; static char *test_cmd = NULL; @@ -685,10 +685,15 @@ seconds_to_pow2ns(int seconds) static void parseargs(int argc, char *argv[]) { + struct timespec ts; int longindex; int c; const char *lopt; + /* Get the default value of timeout_sec from the default timeout. */ + pow2ns_to_ts(timeout, &ts); + timeout_sec = ts.tv_sec; + /* * if we end with a 'd' aka 'watchdogd' then we are the daemon program, * otherwise run as a command line utility. @@ -731,9 +736,9 @@ parseargs(int argc, char *argv[]) case 't': timeout_sec = atoi(optarg); timeout = parse_timeout_to_pow2ns(c, NULL, optarg); - if (debugging) - printf("Timeout is 2^%d nanoseconds\n", - timeout); + if (debugging) + printf("Timeout is 2^%d nanoseconds\n", + timeout); break; case 'T': carp_thresh_seconds = @@ -771,6 +776,9 @@ parseargs(int argc, char *argv[]) } } + if (nap > timeout_sec / 2) + nap = timeout_sec / 2; + if (carp_thresh_seconds == -1) carp_thresh_seconds = nap; @@ -779,10 +787,7 @@ parseargs(int argc, char *argv[]) if (is_daemon && timeout < WD_TO_1SEC) errx(EX_USAGE, "-t argument is less than one second."); if (pretimeout_set) { - struct timespec ts; - - pow2ns_to_ts(timeout, &ts); - if (pretimeout >= (uintmax_t)ts.tv_sec) { + if (pretimeout >= timeout_sec) { errx(EX_USAGE, "pretimeout (%d) >= timeout (%d -> %ld)\n" "see manual section TIMEOUT RESOLUTION",