Date: Sun, 28 Oct 2012 09:34:33 -0500 (CDT) From: "Matthew D.Fuller" <fullermd@over-yonder.net> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/173153: [rc.d] [patch] $netwait_ip should be more parallel Message-ID: <3XqM090QzTzYPB@draco.over-yonder.net> Resent-Message-ID: <201210281440.q9SEe1eJ087310@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3XqM090QzTzYPB>