From 96ef98558c7df1b5949acf867d79ca3815dcb095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Fri, 20 Sep 2024 15:13:09 +0200 Subject: [PATCH] Don't enable timeouts in dns_dispatch for incoming transfers The dns_dispatch_add() call in the dns_xfrin unit had hardcoded 30 second limit. This meant that any incoming transfer would be stopped in it didn't finish within 30 seconds limit. Additionally, dns_xfrin callback was ignoring the return value from dns_dispatch_getnext() when restarting the reading from the TCP stream; this could cause transfers to get stuck waiting for a callback that would never come due to the dns_dispatch having already been shut down. Call the dns_dispatch_add() without a timeout and properly handle the result code from the dns_dispatch_getnext(). --- lib/dns/xfrin.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 3d5a175202..99599b8772 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -1268,15 +1268,10 @@ xfrin_start(dns_xfrin_t *xfr) { dns_xfrin_gettransporttype(xfr)); } - /* - * XXX: timeouts are hard-coded to 30 seconds; this needs to be - * configurable. - */ - CHECK(dns_dispatch_add(xfr->disp, xfr->loop, 0, 30000, - &xfr->primaryaddr, xfr->transport, - xfr->tlsctx_cache, xfrin_connect_done, - xfrin_send_done, xfrin_recv_done, xfr, &xfr->id, - &xfr->dispentry)); + CHECK(dns_dispatch_add( + xfr->disp, xfr->loop, 0, 0, &xfr->primaryaddr, xfr->transport, + xfr->tlsctx_cache, xfrin_connect_done, xfrin_send_done, + xfrin_recv_done, xfr, &xfr->id, &xfr->dispentry)); /* Set the maximum timer */ if (xfr->max_time_timer == NULL) { @@ -1994,7 +1989,10 @@ xfrin_recv_done(isc_result_t result, isc_region_t *region, void *arg) { * Read the next message. */ dns_message_detach(&msg); - dns_dispatch_getnext(xfr->dispentry); + result = dns_dispatch_getnext(xfr->dispentry); + if (result != ISC_R_SUCCESS) { + goto failure; + } isc_interval_t interval; isc_interval_set(&interval, dns_zone_getidlein(xfr->zone), 0);