From d73e4784f2c5a743875871e96ae1888fcf0f1078 Mon Sep 17 00:00:00 2001 From: Petr Jelinek Date: Mon, 18 Dec 2017 22:08:12 +0100 Subject: [PATCH] Display 0 ttl for stale DNS entries in SHOW DNS_HOSTS --- src/admin.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/admin.c b/src/admin.c index a92fffd..480185c 100644 --- a/src/admin.c +++ b/src/admin.c @@ -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) -- 2.40.0