Compare commits

...

1 Commits

Author SHA1 Message Date
Colin Vidal
afabcefdb8 centralize fetch timed out detection
When a fetch request timed out, rctx_timedout is called and it checks if
the fetch expiration time is reached or not. If it is not, it updates
some internal state (next_server and no_response to true), so the next
function called (rctx_done) will eventually re-run a new fetch. (either
trying a new server or re-sending to the same server). Those both flows
eventually both calls fctx_create which initiate a new request.

One of the pre-requires that fctx_create does is also to check if the
fetch expiration time is reached or not. Instead of having two places
checking for the expiration time in the same overall flow, remove the
rctx_timedout fetch expiration check.

Keeping both checks can lead to subtle bug if something specific needs
to be done (i.e. throwing an EDE error) in case of expiration detection,
as the writer needs to think there are two places to change, for the
same flow. Depending on the timing, this specific thing might be or not
be called, and only digging into logs and comparing the two executions
would explain why.
2025-02-19 17:48:03 +01:00

View File

@@ -7939,27 +7939,15 @@ rctx_timedout(respctx_t *rctx) {
fetchctx_t *fctx = rctx->fctx;
if (rctx->result == ISC_R_TIMEDOUT) {
isc_time_t now;
inc_stats(fctx->res, dns_resstatscounter_querytimeout);
FCTX_ATTR_CLR(fctx, FCTX_ATTR_ADDRWAIT);
fctx->timeout = true;
fctx->timeouts++;
now = isc_time_now();
/* netmgr timeouts are accurate to the millisecond */
if (isc_time_microdiff(&fctx->expires, &now) < US_PER_MS) {
FCTXTRACE("query timed out; stopped trying to make "
"fetch happen");
dns_ede_add(&fctx->edectx, DNS_EDE_NOREACHABLEAUTH,
NULL);
} else {
FCTXTRACE("query timed out; trying next server");
/* try next server */
rctx->no_response = true;
rctx->finish = NULL;
rctx->next_server = true;
}
FCTXTRACE("query timed out; trying next server");
rctx->no_response = true;
rctx->finish = NULL;
rctx->next_server = true;
rctx_done(rctx, rctx->result);
return ISC_R_COMPLETE;