]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: shorten default timeout with localhost and async resolving
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 29 Apr 2014 10:04:43 +0000 (12:04 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 29 Apr 2014 13:23:11 +0000 (15:23 +0200)
When chronyd is compiled with asynchronous name resolving, it should
always respond quickly. Shorten the default chronyc timeout for
localhost.

chrony.texi.in
client.c

index 583d5ed6289c639281f6a005c8a8a453920e1be3..e7ccb94c3d02d6637f700670490f80e3300f5706 100644 (file)
@@ -4266,7 +4266,9 @@ in milliseconds.  If no response is received from @code{chronyd}, the timeout is
 doubled and the request is resent.  The maximum number of retries is configured
 with the @code{retries} command (@pxref{retries command}).
 
-The default is 1000 milliseconds.
+By default, the timeout is 1000 milliseconds or 100 milliseconds if
+@code{chronyc} is contacting localhost (i.e. the `-h' option wasn't specified)
+and @code{chronyd} was compiled with asynchronous name resolving.
 @c }}}
 @c {{{ tracking
 @node tracking command
index a973963b786f7fcb4c54542422d55fe0213efdd4..f46b19858ad07900f3323931479fc5534c4742a7 100644 (file)
--- a/client.c
+++ b/client.c
@@ -2703,7 +2703,7 @@ main(int argc, char **argv)
   const char *progname = argv[0];
   const char *hostname = "localhost";
   const char *conf_file = DEFAULT_CONF_FILE;
-  int quit = 0, ret = 1, multi = 0, auto_auth = 0;
+  int quit = 0, ret = 1, multi = 0, auto_auth = 0, short_timeout = 1;
   int port = DEFAULT_CANDM_PORT;
 
   /* Parse command line options */
@@ -2713,6 +2713,7 @@ main(int argc, char **argv)
       if (*argv) {
         hostname = *argv;
       }
+      short_timeout = 0;
     } else if (!strcmp(*argv, "-p")) {
       ++argv, --argc;
       if (*argv) {
@@ -2746,6 +2747,12 @@ main(int argc, char **argv)
     }
   }
 
+  if (short_timeout) {
+#ifdef FEAT_ASYNCDNS
+    initial_timeout /= 10;
+#endif
+  }
+
   if (isatty(0) && isatty(1) && isatty(2)) {
     on_terminal = 1;
   }