]> granicus.if.org Git - pgbouncer/commitdiff
Display 0 ttl for stale DNS entries in SHOW DNS_HOSTS
authorPetr Jelinek <pjmodos@pjmodos.net>
Mon, 18 Dec 2017 21:08:12 +0000 (22:08 +0100)
committerPetr Jelinek <pjmodos@pjmodos.net>
Mon, 18 Dec 2017 21:08:18 +0000 (22:08 +0100)
src/admin.c

index a92fffd370eab49612c1a87f2c0ef9ac8b1d4756..480185c210c974512de21ebbc49643317b0569db 100644 (file)
@@ -869,7 +869,13 @@ static void dns_name_cb(void *arg, const char *name, const struct addrinfo *ai,
        }
        *s = 0;
 
-       pktbuf_write_DataRow(buf, "sqs", name, (ttl - now) / USEC, adrs);
+       /*
+        * Ttl can be smaller than now if we are waiting for dns reply for long.
+        *
+        * It's better to show 0 in that case as otherwise it confuses users into
+        * thinking that there is large ttl for the name.
+        */
+       pktbuf_write_DataRow(buf, "sqs", name, ttl < now ? 0 : (ttl - now) / USEC, adrs);
 }
 
 static bool admin_show_dns_hosts(PgSocket *admin, const char *arg)