From 7f5beb751d5a70b93e4f0c7ff0d89d77f67ad832 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Fri, 5 May 2023 11:22:02 +0000 Subject: [PATCH 1/3] Add nslookup test with a delayed input The added test checks the stdin input mode of nslookup with an added delay to confirm that [GL #4044] is fixed. --- bin/tests/system/nslookup/tests.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bin/tests/system/nslookup/tests.sh b/bin/tests/system/nslookup/tests.sh index 1978eb40f3..abde65c98f 100644 --- a/bin/tests/system/nslookup/tests.sh +++ b/bin/tests/system/nslookup/tests.sh @@ -44,6 +44,22 @@ grep "1.2.3.4" nslookup.out${n} > /dev/null || ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status+ret)) +# See [GL #4044] +n=$((n+1)) +echo_i "Check A only lookup with a delayed stdin input ($n)" +ret=0 +(sleep 6 && echo "server 10.53.0.1" && echo "a-only.example.net.") | $NSLOOKUP -port=${PORT} 2> nslookup.err${n} > nslookup.out${n} || ret=1 +lines=$(wc -l < nslookup.err${n}) +test $lines -eq 0 || ret=1 +lines=$(grep -c "Server:" nslookup.out${n}) +test $lines -eq 1 || ret=1 +lines=$(grep -c a-only.example.net nslookup.out${n}) +test $lines -eq 1 || ret=1 +grep "1.2.3.4" nslookup.out${n} > /dev/null || ret=1 +grep "timed out" nslookup.out${n} > /dev/null && ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=$((status+ret)) + n=$((n+1)) echo_i "Check AAAA only lookup ($n)" ret=0 From 0c751ce72e828a0ab3783e2e5a6cad0da2d18ffd Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Fri, 5 May 2023 10:46:37 +0000 Subject: [PATCH 2/3] Update the event loop's time after executing a task Tasks can block for a long time, especially when used by tools in interactive mode. Update the event loop's time to avoid unexpected errors when processing later events during the same callback. For example, newly started timers can fire too early, because the current time was stale. See the note about uv_update_time() in the https://docs.libuv.org/en/v1.x/timer.html#c.uv_timer_start page. --- lib/isc/netmgr/netmgr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 00a7945edb..b19d468820 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -847,6 +847,16 @@ isc__nm_async_task(isc__networker_t *worker, isc__netievent_t *ev0) { result = isc_task_run(ievent->task); + /* + * Tasks can block for a long time, especially when used by tools in + * interactive mode. Update the event loop's time to avoid unexpected + * errors when processing later events during the same callback. + * For example, newly started timers can fire too early, because the + * current time was stale. See the note about uv_update_time() in the + * https://docs.libuv.org/en/v1.x/timer.html#c.uv_timer_start page. + */ + uv_update_time(&worker->loop); + switch (result) { case ISC_R_QUOTA: isc_task_ready(ievent->task); From 7f70809d91d4aaaf739d96cf61b0246bcbc17d8c Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Fri, 5 May 2023 11:02:06 +0000 Subject: [PATCH 3/3] Add a CHANGES note for [GL #4044] --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 7a6c458cae..a4915f76e3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +6200. [bug] Fix nslookup erroneously reporting a timeout when the + input is delayed. [GL #4044] + 6198. [func] Remove the holes in the isc_result_t enum to compact the isc_result tables. [GL #4149]