From owner-freebsd-bugs@FreeBSD.ORG Sun Oct 28 14:40:01 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9239A686 for ; Sun, 28 Oct 2012 14:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (unknown [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 57FFD8FC14 for ; Sun, 28 Oct 2012 14:40:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q9SEe1Xl087311 for ; Sun, 28 Oct 2012 14:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q9SEe1eJ087310; Sun, 28 Oct 2012 14:40:01 GMT (envelope-from gnats) Resent-Date: Sun, 28 Oct 2012 14:40:01 GMT Resent-Message-Id: <201210281440.q9SEe1eJ087310@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Matthew D.Fuller" Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AFA574A6 for ; Sun, 28 Oct 2012 14:34:41 +0000 (UTC) (envelope-from fullermd@over-yonder.net) Received: from thyme.infocus-llc.com (server.infocus-llc.com [206.156.254.44]) by mx1.freebsd.org (Postfix) with ESMTP id 825B38FC0C for ; Sun, 28 Oct 2012 14:34:40 +0000 (UTC) Received: from draco.over-yonder.net (c-75-65-60-66.hsd1.ms.comcast.net [75.65.60.66]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by thyme.infocus-llc.com (Postfix) with ESMTPSA id CDAFC37B583 for ; Sun, 28 Oct 2012 09:34:33 -0500 (CDT) Received: by draco.over-yonder.net (Postfix, from userid 100) id 3XqM090QzTzYPB; Sun, 28 Oct 2012 09:34:33 -0500 (CDT) Message-Id: <3XqM090QzTzYPB@draco.over-yonder.net> Date: Sun, 28 Oct 2012 09:34:33 -0500 (CDT) From: "Matthew D.Fuller" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/173153: [rc.d] [patch] $netwait_ip should be more parallel X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: "Matthew D.Fuller" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Oct 2012 14:40:01 -0000 >Number: 173153 >Category: bin >Synopsis: [rc.d] [patch] $netwait_ip should be more parallel >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Oct 28 14:40:01 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Matthew D. Fuller >Release: FreeBSD 9.0-STABLE amd64 >Organization: >Environment: System: FreeBSD draco.over-yonder.net 9.0-STABLE FreeBSD 9.0-STABLE #0 r237357: Thu Jun 21 01:21:37 CDT 2012 root@draco.over-yonder.net:/usr/obj/usr/src/sys/DRACO amd64 >Description: /etc/rc.d/netwait allows a list of IP's to be specified in $netwait_ip, and tries until $netwait_timeout (def 60) seconds pass. The current incarnation takes each IP in turn, and tries for $netwait_timeout seconds. This is rather unpleasant, since it means that firstly, it can take up to $netwait_timeout * N seconds to pass through, and secondly, if the first IP in the list isn't available, it'll take at least _timeout seconds. Any of the IP's should equally satisfy things; if the second (or later) isn't sufficient, it shouldn't be in the list, and if it is, it should be as good right off the bat as a minute (or more) later. netwait should look over the list internally each period, and go until the timeout hits. Attached patch makes a minimal change to get reasonably close; it still waits a second on each IP, so the 5th IP in the list won't get tried until 4 seconds have elapsed. If the timeout isn't divisible by the number of IP's specified, it can go overtime by the modulus (or by the number of IP's, if it's greater than the timeout). I don't consider any of those showstoppers; I have a hard time imagining cases where more than 2 or 3 IP's could be in the list. Possibly cosmetics of the messages may benefit from further adjustment; I've chosen to leave that shed unbiked. >How-To-Repeat: >Fix: Index: netwait =================================================================== --- netwait (revision 242186) +++ netwait (working copy) @@ -67,11 +67,10 @@ # Handle SIGINT (Ctrl-C); force abort of while() loop trap break SIGINT - for ip in ${netwait_ip}; do - echo -n "Waiting for ${ip} to respond to ICMP" - - count=1 - while [ ${count} -le ${netwait_timeout} ]; do + count=${netwait_timeout} + echo -n "Waiting for ${netwait_ip} to respond to ICMP" + while [ ${count} -ge 0 ]; do + for ip in ${netwait_ip}; do /sbin/ping -t 1 -c 1 -o ${ip} >/dev/null 2>&1 rc=$? @@ -82,9 +81,8 @@ echo '.' return fi - count=$((count+1)) + count=$((count-1)) done - echo ': No response from host.' done # Restore default SIGINT handler >Release-Note: >Audit-Trail: >Unformatted: