From: Arran Cudbard-Bell Date: Wed, 25 Aug 2021 16:57:48 +0000 (-0500) Subject: Fix unbound timeouts X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfe6750760511fcbff3d33cdba2205c81b70f5b2;p=thirdparty%2Ffreeradius-server.git Fix unbound timeouts --- diff --git a/src/modules/rlm_unbound/rlm_unbound.c b/src/modules/rlm_unbound/rlm_unbound.c index 290b1c2840b..48d2bd4213a 100644 --- a/src/modules/rlm_unbound/rlm_unbound.c +++ b/src/modules/rlm_unbound/rlm_unbound.c @@ -61,6 +61,7 @@ typedef struct { rlm_unbound_thread_t *t; //!< Thread running this request int done; //!< Indicator that the callback has been called ///< Negative values indicate errors. + bool timedout; //!< Request timedout. fr_type_t return_type; //!< Data type to parse results into bool has_priority; //!< Does the returned data start with a priority field uint16_t count; //!< Number of results to return @@ -263,9 +264,10 @@ static void xlat_unbound_timeout(UNUSED fr_event_list_t *el, UNUSED fr_time_t no unbound_request_t *ur = talloc_get_type_abort(uctx, unbound_request_t); request_t *request = ur->request; - REDEBUG("Timeout waiting for DNS resolution"); - talloc_free(ur); + REDEBUG("Timeout waiting for DNS resolution");; unlang_interpret_mark_runnable(request); + + ur->timedout = true; } /* @@ -281,7 +283,6 @@ static void xlat_unbound_signal(request_t *request, UNUSED void *instance, UNUSE if (ur->ev) (void)fr_event_timer_delete(&ur->ev); RDEBUG2("Forcefully cancelling pending unbound request"); - talloc_free(ur); } /* @@ -295,6 +296,11 @@ static xlat_action_t xlat_unbound_resume(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *o fr_value_box_t *vb; unbound_request_t *ur = talloc_get_type_abort(rctx, unbound_request_t); + /* + * Request timed out + */ + if (ur->timedout) return XLAT_ACTION_FAIL; + #define RCODEERROR(_code, _message) case _code: \ REDEBUG(_message, ur->t->inst->name); \ goto error diff --git a/src/tests/modules/unbound/dns.unlang b/src/tests/modules/unbound/dns.unlang index b13a0208e7a..b4302126ca6 100644 --- a/src/tests/modules/unbound/dns.unlang +++ b/src/tests/modules/unbound/dns.unlang @@ -108,7 +108,8 @@ if (&Tmp-String-1 != "") { test_fail } -if (&Module-Failure-Message != "dns - Nonexistent domain name") { +# Running this on macOS produces a timeout due to the nonexistent TLD +if ((&Module-Failure-Message != "dns - Nonexistent domain name") && (&Module-Failure-Message != "Timeout waiting for DNS resolution")) { test_fail }