From 37ad9d9f0f706eb747a22ad7b1433bdf9105eb0b Mon Sep 17 00:00:00 2001 From: mrabine Date: Sat, 28 Nov 2026 11:44:34 +0100 Subject: [PATCH 1/2] Submit the cancellations when stopping the proactor --- core/include/join/proactor.hpp | 3 ++- core/include/join/proactor_uring.hpp | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/include/join/proactor.hpp b/core/include/join/proactor.hpp index 78b30cd6..ef956992 100644 --- a/core/include/join/proactor.hpp +++ b/core/include/join/proactor.hpp @@ -592,8 +592,9 @@ class join::BasicProactor : public join::EventHandler /** * @brief cancel all in-flight operations. + * @param flush submit the cancellations if true. */ - void cancelAllOperations () noexcept; + void cancelAllOperations (bool flush) noexcept; /** * @brief invoke function. diff --git a/core/include/join/proactor_uring.hpp b/core/include/join/proactor_uring.hpp index 9ca4ff1e..c062a83d 100644 --- a/core/include/join/proactor_uring.hpp +++ b/core/include/join/proactor_uring.hpp @@ -181,7 +181,7 @@ void join::BasicProactor::stop (bool sync) noexcept if (isProactorThread ()) { _running.store (false, std::memory_order_release); - cancelAllOperations (); + cancelAllOperations (true); return; } @@ -190,7 +190,7 @@ void join::BasicProactor::stop (bool sync) noexcept return; } - writeCommand ({CommandType::Stop, nullptr, sync, nullptr, nullptr, nullptr}); + writeCommand ({CommandType::Stop, nullptr, true, nullptr, nullptr, nullptr}); if (JOIN_LIKELY (sync)) { @@ -547,11 +547,7 @@ void join::BasicProactor::processCommand (const Command& cmd) noexcept case CommandType::Stop: _running.store (false, std::memory_order_release); - cancelAllOperations (); - if (JOIN_UNLIKELY (cmd.flush)) - { - io_uring_submit (&_ring); - } + cancelAllOperations (cmd.flush); break; case CommandType::Flush: @@ -720,7 +716,7 @@ int join::BasicProactor::cancelOperation (IoOperation& op, bool flush) // METHOD : cancelAllOperations // ========================================================================= template -void join::BasicProactor::cancelAllOperations () noexcept +void join::BasicProactor::cancelAllOperations (bool flush) noexcept { for (IoOperation* op : _pendingOps) { @@ -731,6 +727,11 @@ void join::BasicProactor::cancelAllOperations () noexcept } cancelOperation (*op, false); } + + if (JOIN_LIKELY (flush)) + { + io_uring_submit (&_ring); + } } // ========================================================================= From f9726d6d77e4e7418fd920e06c7575172d5962cc Mon Sep 17 00:00:00 2001 From: mrabine Date: Sat, 28 Nov 2026 11:54:53 +0100 Subject: [PATCH 2/2] Align the epoll stop with io_uring --- core/include/join/proactor_epoll.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/include/join/proactor_epoll.hpp b/core/include/join/proactor_epoll.hpp index 3151245b..5ff6f85e 100644 --- a/core/include/join/proactor_epoll.hpp +++ b/core/include/join/proactor_epoll.hpp @@ -72,7 +72,7 @@ inline void join::BasicProactor::stop (bool sync) noexcept { if (isProactorThread ()) { - cancelAllOperations (); + cancelAllOperations (true); _reactor.stop (false); return; } @@ -82,7 +82,7 @@ inline void join::BasicProactor::stop (bool sync) noexcept return; } - writeCommand ({CommandType::Stop, nullptr, sync, nullptr, nullptr, nullptr}); + writeCommand ({CommandType::Stop, nullptr, true, nullptr, nullptr, nullptr}); if (JOIN_LIKELY (sync)) { @@ -400,7 +400,7 @@ inline void join::BasicProactor::processCommand (const Command& cmd) noexcept break; case CommandType::Stop: - cancelAllOperations (); + cancelAllOperations (cmd.flush); _reactor.stop (false); break; @@ -586,7 +586,7 @@ inline int join::BasicProactor::cancelOperation (IoOperation& op, [[maybe_unused // CLASS : BasicProactor // METHOD : cancelAllOperations // ========================================================================= -inline void join::BasicProactor::cancelAllOperations () noexcept +inline void join::BasicProactor::cancelAllOperations ([[maybe_unused]] bool flush) noexcept { for (size_t fd = 0; fd < _readOps.size (); ++fd) {