From fullermd@over-yonder.net  Sun Oct 28 14:34:41 2012
Return-Path: <fullermd@over-yonder.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id AFA574A6
	for <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <fullermd@over-yonder.net>
Reply-To: Matthew D.Fuller <fullermd@over-yonder.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [rc.d] [patch] $netwait_ip should be more parallel
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         173153
>Category:       bin
>Synopsis:       [rc.d] [patch] $netwait_ip should be more parallel
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>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:  Tue Oct 30 07:53:07 UTC 2012
>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:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue Oct 30 07:52:58 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=173153 
>Unformatted:
