From 995aa0c582f93fb547c2629c4e9b5f9620febf3c Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Wed, 16 Jul 2025 18:41:41 +0200 Subject: [PATCH] refactor(userspace/falco): remove duplicate condition test handled is test a second time for the same while it's already part of the initial entry condition. Signed-off-by: Samuel Gaist --- userspace/falco/atomic_signal_handler.h | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/userspace/falco/atomic_signal_handler.h b/userspace/falco/atomic_signal_handler.h index 5630eb3c..f141d9b5 100644 --- a/userspace/falco/atomic_signal_handler.h +++ b/userspace/falco/atomic_signal_handler.h @@ -85,23 +85,21 @@ public: inline bool handle(std::function f) { if(triggered() && !handled()) { std::unique_lock lock(m_mtx); - if(!handled()) { - try { - f(); - // note: the action may have forcely reset - // the signal handler, so we don't want to create - // an inconsistent state - if(triggered()) { - m_handled.store(true, std::memory_order_seq_cst); - } - } catch(std::exception&) { - if(triggered()) { - m_handled.store(true, std::memory_order_seq_cst); - } - throw; + try { + f(); + // note: the action may have forcely reset + // the signal handler, so we don't want to create + // an inconsistent state + if(triggered()) { + m_handled.store(true, std::memory_order_seq_cst); } - return true; + } catch(std::exception&) { + if(triggered()) { + m_handled.store(true, std::memory_order_seq_cst); + } + throw; } + return true; } return false; }