From 5b457116dbeef1cac74a52d1dcc89a812adec68c Mon Sep 17 00:00:00 2001 From: Libor Peltan Date: Wed, 8 Jan 2025 09:05:44 +0100 Subject: ctl: fix ctl stuck when abort sent to nonexisting conf txn... ...this appeared as a regression when implementing concurrent CTL --- src/knot/ctl/process.c | 9 ++++++--- tests-extra/tests/ctl/basic/test.py | 8 ++++++++ 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. +/* Copyright (C) 2025 CZ.NIC, z.s.p.o. 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() -- cgit v1.2.3