From 1b7aef5a882b39f04ca12e325d66a7d03d580519 Mon Sep 17 00:00:00 2001 From: Sara Dickinson Date: Thu, 23 Feb 2017 14:49:17 +0000 Subject: [PATCH] Add a new GETDNS_RETURN code for the case where no upstream is considered valid and hence a query cannot even be scheduled. Only applies when using purely stateful transports. This can happen when using Stubby if there are problems with connections to upstreams. --- src/const-info.c | 2 ++ src/getdns/getdns_extra.h.in | 2 ++ src/stub.c | 5 ++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/const-info.c b/src/const-info.c index a71f928a..0022a768 100644 --- a/src/const-info.c +++ b/src/const-info.c @@ -24,6 +24,7 @@ static struct const_info consts_info[] = { { 310, "GETDNS_RETURN_MEMORY_ERROR", GETDNS_RETURN_MEMORY_ERROR_TEXT }, { 311, "GETDNS_RETURN_INVALID_PARAMETER", GETDNS_RETURN_INVALID_PARAMETER_TEXT }, { 312, "GETDNS_RETURN_NOT_IMPLEMENTED", GETDNS_RETURN_NOT_IMPLEMENTED_TEXT }, + { 398, "GETDNS_RETURN_NO_UPSTREAM_AVAILABLE", GETDNS_RETURN_NO_UPSTREAM_AVAILABLE_TEXT }, { 399, "GETDNS_RETURN_NEED_MORE_SPACE", GETDNS_RETURN_NEED_MORE_SPACE_TEXT }, { 400, "GETDNS_DNSSEC_SECURE", GETDNS_DNSSEC_SECURE_TEXT }, { 401, "GETDNS_DNSSEC_BOGUS", GETDNS_DNSSEC_BOGUS_TEXT }, @@ -218,6 +219,7 @@ static struct const_name_info consts_name_info[] = { { "GETDNS_RETURN_GOOD", 0 }, { "GETDNS_RETURN_INVALID_PARAMETER", 311 }, { "GETDNS_RETURN_MEMORY_ERROR", 310 }, + { "GETDNS_RETURN_NO_UPSTREAM_AVAILABLE", 398}, { "GETDNS_RETURN_NEED_MORE_SPACE", 399 }, { "GETDNS_RETURN_NOT_IMPLEMENTED", 312 }, { "GETDNS_RETURN_NO_SUCH_DICT_NAME", 305 }, diff --git a/src/getdns/getdns_extra.h.in b/src/getdns/getdns_extra.h.in index 5abf39e7..a76564eb 100644 --- a/src/getdns/getdns_extra.h.in +++ b/src/getdns/getdns_extra.h.in @@ -56,6 +56,8 @@ extern "C" { * \defgroup Ureturnvaluesandtext Additional return values and texts * @{ */ +#define GETDNS_RETURN_NO_UPSTREAM_AVAILABLE ((getdns_return_t) 398 ) +#define GETDNS_RETURN_NO_UPSTREAM_AVAILABLE_TEXT "None of the configured upstreams could be used to send queries on the specified transports" #define GETDNS_RETURN_NEED_MORE_SPACE ((getdns_return_t) 399 ) #define GETDNS_RETURN_NEED_MORE_SPACE_TEXT "The buffer was too small" /** @} diff --git a/src/stub.c b/src/stub.c index 37c025a8..369c0d38 100644 --- a/src/stub.c +++ b/src/stub.c @@ -520,7 +520,7 @@ stub_cleanup(getdns_network_req *netreq) static void upstream_failed(getdns_upstream *upstream, int during_setup) { - DEBUG_STUB("%s %-35s: FD: %d During setup = %d\n", + DEBUG_STUB("%s %-35s: FD: %d Failure during connection setup = %d\n", STUB_DEBUG_CLEANUP, __FUNC__, upstream->fd, during_setup); /* Fallback code should take care of queue queries and then close conn when idle.*/ @@ -2023,8 +2023,7 @@ _getdns_submit_stub_request(getdns_network_req *netreq) * All other set up is done async*/ fd = upstream_find_for_netreq(netreq); if (fd == -1) - /* Handle better, will give unhelpful error is some cases */ - return GETDNS_RETURN_GENERIC_ERROR; + return GETDNS_RETURN_NO_UPSTREAM_AVAILABLE; getdns_transport_list_t transport = netreq->transports[netreq->transport_current];