[Git][NTPsec/ntpsec][master] Add some instrumentation to chase down hangs in ntpq.

Eric S. Raymond gitlab at mg.gitlab.com
Wed Nov 9 15:07:20 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
5a12a6e1 by Eric S. Raymond at 2016-11-09T10:05:47-05:00
Add some instrumentation to chase down hangs in ntpq.

- - - - -


3 changed files:

- ntpq/ntpq
- pylib/packet.py
- pylib/util.py


Changes:

=====================================
ntpq/ntpq
=====================================
--- a/ntpq/ntpq
+++ b/ntpq/ntpq
@@ -289,7 +289,8 @@ usage: help [ command ]
         report = PeerSummary(mode,
                              self.pktversion,
                              self.showhostnames,
-                             self.wideremote)
+                             self.wideremote,
+                             debug=interpreter.debug)
         maxhostlen = 0
         if len(self.chosts) > 1:
             maxhostlen = max([len(host) for (host, _af) in self.chosts])
@@ -520,7 +521,11 @@ usage: timeout [ msec ]
             value = queried[name]
             if fmt in (NTP_ADD, NTP_ADP):
                 if self.showhostnames:
+                    if self.debug:
+                        self.say("DNS lookup begins...")
                     value = canonicalize_dns(value, family=self.ai_family)
+                    if self.debug:
+                        self.say("DNS lookup complete.")
                 self.say("%s  %s\n" % (legend, value))
             elif fmt == NTP_STR:
                 if value:
@@ -655,7 +660,7 @@ usage: hostnames [ yes|no ]
     def help_debug(self):
         self.say("""\
 function: set/change debugging level
-usage: debug [ no|more|less ]
+usage: debug [ no|more|less|n ]
 """)
 
     def do_exit(self, line):


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -543,6 +543,8 @@ class Mode6Session:
         bail = 0
         warn = sys.stderr.write
 
+        if self.debug:
+            warn("Fragment collection begins %d\n")
         # Loop until we have an error or a complete response.  Nearly all
         # code paths to loop again use continue.
         while True:


=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -69,11 +69,12 @@ def termsize():
 
 class PeerSummary:
     "Reusable report generator for peer statistics"
-    def __init__(self, displaymode, pktversion, showhostnames, wideremote):
+    def __init__(self, displaymode, pktversion, showhostnames, wideremote, debug=0):
         self.displaymode = displaymode		# peers/apeers.opeers
         self.pktversion = pktversion		# interpretation of flash bits
         self.showhostnames = showhostnames	# If false, display numeric IPs
         self.wideremote = wideremote		# show wide remote names?
+        self.debug = debug
         # By default, the peer spreadsheet layout is designed so lines just
         # fit in 80 characters. This tells us how much extra horizontal space
         # we have available on a wider terminal emulator
@@ -229,7 +230,11 @@ class PeerSummary:
             clock_name = srchost
         elif self.showhostnames:
             try:
+                if self.debug:
+                    self.say("DNS lookup begins...")
                 clock_name = canonicalize_dns(srcadr)
+                if self.debug:
+                    self.say("DNS lookup ends.")
             except TypeError:
                 return ''
         else:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/5a12a6e12954beaa529f386b037a79bf6d8b2c2c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161109/4d38af64/attachment.html>


More information about the vc mailing list