Index | Thread | Search

From:
Andrew Hewus Fresh <andrew@afresh1.com>
Subject:
Increase initial timeout for fw_update(8)
To:
tech@openbsd.org
Date:
Sat, 11 Apr 2026 11:08:41 -0700

Download raw body.

Thread
sthen@ suggested that in some cases a 12 second timeout might not be
enough to make a connection and start the transfer.

This adjusts the initial timeout to 60 seconds, switching back to a 12s
timeout after.

While here, use arithmetic expressions instead of ksh tests.

Comments, OK?

Index: fw_update.sh
===================================================================
RCS file: /cvs/src/usr.sbin/fw_update/fw_update.sh,v
diff -u -p -r1.66 fw_update.sh
--- fw_update.sh	26 Dec 2025 18:19:46 -0000	1.66
+++ fw_update.sh	11 Apr 2026 18:06:18 -0000
@@ -103,6 +103,7 @@ spin() {

 fetch() {
 	local _src="${FWURL}/${1##*/}" _dst=$1 _user=_file _exit _error=''
+	local _timeout=60
 	local _ftp_errors="$FD_DIR/ftp_errors"
 	rm -f "$_ftp_errors"

@@ -127,12 +128,15 @@ fetch() {
 	) & FTPPID=$!
 	set +o monitor

+	# Tmeout after 60 seconds for initial bytes
+	# and after 12 seconds for additional bytes
 	SECONDS=0
 	_last=0
 	while kill -0 -"$FTPPID" 2>/dev/null; do
-		if [[ $SECONDS -gt 12 ]]; then
+		if (( SECONDS > _timeout )); then
+			_timeout=12
 			set -- $( ls -ln "$_dst" 2>/dev/null )
-			if [[ $_last -ne $5 ]]; then
+			if (( _last != $5 )); then
 				_last=$5
 				SECONDS=0
 				spin