summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibor Peltan <libor.peltan@nic.cz>2025-01-08 09:05:44 +0100
committerDaniel Salzman <daniel.salzman@nic.cz>2025-01-08 12:30:01 +0100
commit5b457116dbeef1cac74a52d1dcc89a812adec68c (patch)
tree53bee6810dbe5d0df7b24b7ec6aa48e73eabd7fe
parentpython: expanded CTL documentation (diff)
downloadknot-5b457116dbeef1cac74a52d1dcc89a812adec68c.tar.xz
knot-5b457116dbeef1cac74a52d1dcc89a812adec68c.zip
ctl: fix ctl stuck when abort sent to nonexisting conf txn...
...this appeared as a regression when implementing concurrent CTL
-rw-r--r--src/knot/ctl/process.c9
-rw-r--r--tests-extra/tests/ctl/basic/test.py8
2 files changed, 14 insertions, 3 deletions
diff --git a/src/knot/ctl/process.c b/src/knot/ctl/process.c
index 7c4fa0207..96bc398e1 100644
--- a/src/knot/ctl/process.c
+++ b/src/knot/ctl/process.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2024 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2025 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -39,6 +39,7 @@ int ctl_process(knot_ctl_t *ctl, server_t *server, int thread_idx, bool *exclusi
while (true) {
// Receive data unit.
+ int cmd_exec = true, cmd_ret = KNOT_EOK;
int ret = knot_ctl_receive(args.ctl, &args.type, &args.data);
if (ret != KNOT_EOK) {
log_ctl_debug("control, failed to receive (%s)",
@@ -107,11 +108,13 @@ int ctl_process(knot_ctl_t *ctl, server_t *server, int thread_idx, bool *exclusi
if ((cmd == CTL_CONF_COMMIT || cmd == CTL_CONF_ABORT) && !*exclusive) {
log_ctl_warning("control, invalid reception of '%s'", cmd_name);
- continue;
+ cmd_exec = false;
}
// Execute the command.
- int cmd_ret = ctl_exec(cmd, &args);
+ if (cmd_exec) {
+ cmd_ret = ctl_exec(cmd, &args);
+ }
switch (cmd_ret) {
case KNOT_EOK:
strip = false;
diff --git a/tests-extra/tests/ctl/basic/test.py b/tests-extra/tests/ctl/basic/test.py
index 4aaea38a7..a5defec8d 100644
--- a/tests-extra/tests/ctl/basic/test.py
+++ b/tests-extra/tests/ctl/basic/test.py
@@ -24,6 +24,14 @@ t.start()
ctl.connect(os.path.join(knot.dir, "knot.sock"))
+# Check conf-abort and conf-commit without conf transaction open.
+
+ctl.send_block(cmd="conf-abort")
+resp = ctl.receive_block()
+
+ctl.send_block(cmd="conf-commit")
+resp = ctl.receive_block()
+
# Add new zone.
ctl.send_block(cmd="conf-begin")
resp = ctl.receive_block()