From: Petr Jelinek Date: Mon, 18 Dec 2017 21:08:12 +0000 (+0100) Subject: Display 0 ttl for stale DNS entries in SHOW DNS_HOSTS X-Git-Tag: pgbouncer_1_8~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d73e4784f2c5a743875871e96ae1888fcf0f1078;p=pgbouncer Display 0 ttl for stale DNS entries in SHOW DNS_HOSTS --- 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)