[ntpsec commit] In ntpdate, implement timeout correctly.

Eric S. Raymond esr at ntpsec.org
Thu Oct 1 23:51:26 UTC 2015


Module:    ntpsec
Branch:    master
Commit:    e60a17edbdfcdabd156d752c6f7f27761b4a0191
Changeset: http://git.ntpsec.org/ntpsec/commit/?id=e60a17edbdfcdabd156d752c6f7f27761b4a0191

Author:    Eric S. Raymond <esr at thyrsus.com>
Date:      Thu Oct  1 19:49:31 2015 -0400

In ntpdate, implement timeout correctly.

---

 scripts/ntpdate | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/scripts/ntpdate b/scripts/ntpdate
index de49c9a..ed488a6 100755
--- a/scripts/ntpdate
+++ b/scripts/ntpdate
@@ -10,9 +10,8 @@
 # Debug this by giving the -n option, which causes it to echo the
 # generated sntp command rather than executing it.
 #
-# Known bugs: (1) Without an explicit -t option, the default timeout is
-# sntp's 5 seconds rather than old ntpdate's 1. (2) The -e and -p options
-# of ntpdate are not yet implemented.  These things could be fixed.
+# Known bug: The -e and -p options of ntpdate are not yet
+# implemented.
 #
 # ntpdate sntp    ntpd    What it does
 # -4      -4      -q -4   Resolve DNS lookups to A records         
@@ -33,13 +32,15 @@
 # -v                      verbose (ntpd is always more verbose than ntpdate)
 #         -B secs         Broadcast timeout        
 #         -b addr         Listen on addr for broadcasts    
-#         -c name         Send concurrent requests to resolved IPs for name      #   
+#         -c name         Send concurrent requests to resolved IPs for name
+#   
 #         -K file         KoD history filename     
 #         -l file         Log to file - is this really useful?     
 #         -M msec         Slew adjustments less than msec,
 #                         step adjustments larger than msec.       
 
 PASSTHROUGH=""
+TIMEOUT="-t 1"
 setclock=yes
 echo=""
 while getopts 46a:bBe:k:no:p:qst:uv opt
@@ -58,7 +59,7 @@ do
 	p) echo "ntpdate: -p is no longer supported." >&2;;
 	q) setclock=no;;
 	s) PASSTHROUGH="$PASSTHROUGH -p";;
-	t) PASSTHROUGH="$PASSTHROUGH -t $OPTARG";;
+	t) PASSTHROUGH="$PASSTHROUGH -t $OPTARG"; TIMEOUT="";;
 	u) ;;
 	v) ;;
     esac
@@ -70,7 +71,7 @@ then
     ADJUST="-s -j"
 fi
 
-$echo sntp $ADJUST $PASSTHROUGH $*
+$echo sntp $ADJUST $TIMEOUT $PASSTHROUGH $*
 
 #end
 



More information about the vc mailing list