From 9930d2ce8fc0873b7a343a3f06c5a0a0eb843b38 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 11 Mar 2019 11:51:02 -0700 Subject: [PATCH] modules/s_dns_resolver: Queue tags when no nameserver is available. --- modules/s_dns_resolver.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/s_dns_resolver.cc b/modules/s_dns_resolver.cc index d1a56b1f6..fb7b2fdd9 100644 --- a/modules/s_dns_resolver.cc +++ b/modules/s_dns_resolver.cc @@ -181,7 +181,7 @@ try tags.at(next) }; - send_query(tag); + submit(tag); } catch(const std::out_of_range &e) { @@ -422,7 +422,19 @@ ircd::net::dns::resolver::queue_query(tag &tag) void ircd::net::dns::resolver::submit(tag &tag) { - assert(ns.is_open()); + if(!ns.is_open() || server.empty()) + { + log::warning + { + net::log, "dns tag:%u submit queued because no nameserver is available.", + tag.id + }; + + queue_query(tag); + return; + } + + assert(!server.empty()); const auto rate(milliseconds(send_rate) / server.size()); const auto elapsed(now() - send_last); if(elapsed >= rate || tags.size() < size_t(send_burst)) @@ -469,6 +481,7 @@ void ircd::net::dns::resolver::send_query(const ip::udp::endpoint &ep, tag &tag) { + assert(ns.is_open()); assert(ns.non_blocking()); assert(!empty(tag.question)); const const_buffer &buf{tag.question};