- auth-load-thread, fix pick up of active transfer after full list.

Add unit test for list of auth transfers.
This commit is contained in:
W.C.A. Wijngaards
2026-10-09 15:55:21 +02:00
parent e23010c18e
commit 7c624d1dcd
7 changed files with 277 additions and 2 deletions
+7 -2
View File
@@ -1110,6 +1110,7 @@ void auth_load_info_release_transfer_in_progress(struct module_env* env)
int
xfr_transfer_grab_active(struct auth_xfer* xfr)
{
int ret;
if(xfr->task_transfer->active_transfer) {
char zname[LDNS_MAX_DOMAINLEN];
dname_str(xfr->name, zname);
@@ -1117,9 +1118,11 @@ xfr_transfer_grab_active(struct auth_xfer* xfr)
"%s", zname);
return 1;
}
xfr->task_transfer->active_transfer = 1;
return auth_load_info_grab_transfer_in_progress(
ret = auth_load_info_grab_transfer_in_progress(
xfr->task_transfer->env);
if(ret)
xfr->task_transfer->active_transfer = 1;
return ret;
}
/** Disable resume timer. */
@@ -1165,6 +1168,7 @@ auth_load_schedule_waiting_pickup(struct module_env* env)
/* Set a timer for zero time, that makes the callback run
* in the event loop, outside of these callback functions.
* There it can handle the waiting xfr task. */
verbose(VERB_ALGO, "schedule auth load resume timer");
auth_load_info->resume_timer_enabled = 1;
auth_load_info->resume_env = env;
auth_load_info->resume_timer = comm_timer_create(
@@ -1245,6 +1249,7 @@ void auth_load_resume_timer_cb(void* arg)
/* Disable the timer */
auth_load_disable_resume_timer(auth_load_info);
verbose(VERB_ALGO, "auth load resume timer");
/* If there are waiting xfrs on the wait_transfer list, pick one up. */
while(1) {
if(!auth_load_resume_transfer(auth_load_info, env))
+5
View File
@@ -6505,6 +6505,11 @@ xfer_link_data(sldns_buffer* pkt, struct auth_xfer* xfr)
void
xfr_pick_up_transfer(struct auth_xfer* xfr, struct module_env* env)
{
if(verbosity >= VERB_ALGO) {
char zname[LDNS_MAX_DOMAINLEN];
dname_str(xfr->name, zname);
verbose(VERB_ALGO, "pick up transfer %s", zname);
}
/* The item is picked up by the worker from the env. */
xfr->task_transfer->worker = env->worker;
xfr->task_transfer->env = env;
+103
View File
@@ -0,0 +1,103 @@
server:
verbosity: 8
num-threads: 1
interface: 127.0.0.1
port: @PORT@
use-syslog: no
directory: ""
pidfile: "unbound.pid"
chroot: ""
username: ""
do-not-query-localhost: no
auth-task-threads: 2
auth-zone:
name: "example1.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example2.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example3.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example4.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example5.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example6.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example7.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example8.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example9.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example10.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example11.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example12.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example13.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example14.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
auth-zone:
name: "example15.com"
for-upstream: yes
for-downstream: yes
master: "127.0.0.1@@TOPORT@"
+16
View File
@@ -0,0 +1,16 @@
BaseName: auth_load_list
Version: 1.0
Description: Perform more transfers than the auth load thread count
CreationDate: Fri 9 Jul 15:00:00 CEST 2026
Maintainer: dr. W.C.A. Wijngaards
Category:
Component:
CmdDepends:
Depends:
Help:
Pre: auth_load_list.pre
Post: auth_load_list.post
Test: auth_load_list.test
AuxFiles:
Passed:
Failure:
+12
View File
@@ -0,0 +1,12 @@
# #-- auth_load_list.post --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# source the test var file when it's there
[ -f .tpkg.var.test ] && source .tpkg.var.test
#
# do your teardown here
. ../common.sh
kill_pid $FWD_PID
kill_pid $UNBOUND_PID
cat fwd.log
cat unbound.log
+74
View File
@@ -0,0 +1,74 @@
# #-- auth_load_list.pre--#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
PRE="../.."
. ../common.sh
# if no threads; exit
if grep -e "define HAVE_PTHREAD 1" -e "define HAVE_SOLARIS_THREADS 1" -e "define HAVE_WINDOWS_THREADS 1" $PRE/config.h; then
echo "have threads"
else
skip_test "no threads"
fi
get_random_port 2
UNBOUND_PORT=$RND_PORT
FWD_PORT=$(($RND_PORT + 1))
echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test
# start forwarder
# create auth_load_list.testns
for((i=1; i<16; i++)); do
cat >>auth_load_list.testns <<EOF
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR AA NOERROR
SECTION QUESTION
example$i.com. IN SOA
SECTION ANSWER
example$i.com. IN SOA ns.example$i.com. hostmaster.example$i.com. 1 3600 900 86400 3600
ENTRY_END
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR AA NOERROR
SECTION QUESTION
example$i.com. IN AXFR
SECTION ANSWER
example$i.com. IN SOA ns.example$i.com. hostmaster.example$i.com. 1 3600 900 86400 3600
example$i.com. IN NS ns.example.net.
EXTRA_PACKET
REPLY QR AA NOERROR
SECTION QUESTION
example$i.com. IN AXFR
SECTION ANSWER
www.example$i.com. IN A 1.2.3.4
example$i.com. IN SOA ns.example$i.com. hostmaster.example$i.com. 1 3600 900 86400 3600
ENTRY_END
EOF
done
get_ldns_testns
$LDNS_TESTNS -p $FWD_PORT auth_load_list.testns >fwd.log 2>&1 &
FWD_PID=$!
echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
# make config file
sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' < auth_load_list.conf > ub.conf
# start unbound in the background
$PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
#valgrind --leak-check=full --show-reachable=yes $PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
UNBOUND_PID=$!
echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
cat .tpkg.var.test
wait_ldns_testns_up fwd.log
wait_unbound_up unbound.log
+60
View File
@@ -0,0 +1,60 @@
# #-- auth_load_list.test --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
PRE="../.."
# do the test
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
name="www.example$i.com"
echo ""
echo "> dig $name"
dig @127.0.0.1 -p $UNBOUND_PORT $name | tee outfile
if grep SERVFAIL outfile; then
echo "> try again"
dig @127.0.0.1 -p $UNBOUND_PORT $name | tee outfile
fi
if grep SERVFAIL outfile; then
echo "> try again"
sleep 1
dig @127.0.0.1 -p $UNBOUND_PORT $name | tee outfile
fi
if grep SERVFAIL outfile; then
echo "> try again"
sleep 1
dig @127.0.0.1 -p $UNBOUND_PORT $name | tee outfile
fi
if grep SERVFAIL outfile; then
echo "> try again"
sleep 1
dig @127.0.0.1 -p $UNBOUND_PORT $name | tee outfile
fi
if grep SERVFAIL outfile; then
echo "> try again"
sleep 3
dig @127.0.0.1 -p $UNBOUND_PORT $name | tee outfile
fi
if grep SERVFAIL outfile; then
echo "> try again"
sleep 3
dig @127.0.0.1 -p $UNBOUND_PORT $name | tee outfile
fi
echo "> check answer"
if grep "1.2.3.4" outfile; then
echo "OK"
else
echo "Not OK"
exit 1
fi
if grep "auth zone example$i.com. details" unbound.log; then
echo "OK"
else
echo "not OK"
exit 1
fi
done
echo "loop done"
exit 0