From 02f1224e1dfa1f14d1fbd86f3c27bf3390970f34 Mon Sep 17 00:00:00 2001 From: Alexander van der Grinten Date: Fri, 20 Mar 2026 19:41:42 +0100 Subject: [PATCH 1/2] post-ack: Fix completion handling in detach() --- include/async/post-ack.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/async/post-ack.hpp b/include/async/post-ack.hpp index fe1528d..8479365 100644 --- a/include/async/post-ack.hpp +++ b/include/async/post-ack.hpp @@ -275,12 +275,15 @@ struct post_ack_agent { auto n = nd->acks_left.fetch_sub(1, std::memory_order_acq_rel); assert(n >= 1); - if(n == 1) + if(n == 1) { mech_->queue_.erase(mech_->queue_.iterator_to(nd)); - // Run the completion handler without locks. - lock.unlock(); - nd->complete(); + // Run the completion handler without locks. + lock.unlock(); + nd->complete(); + }else{ + lock.unlock(); + } ++poll_seq_; if(retire_seq == poll_seq_) // Avoid re-locking. From 36124e3794d647fbc469ba96b68824c82c6000c6 Mon Sep 17 00:00:00 2001 From: Alexander van der Grinten Date: Fri, 20 Mar 2026 19:42:08 +0100 Subject: [PATCH 2/2] post-ack: Increment poll sequence on completion The previous code lost a sequence number when a poll was cancelled. --- include/async/post-ack.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/include/async/post-ack.hpp b/include/async/post-ack.hpp index 8479365..514b388 100644 --- a/include/async/post-ack.hpp +++ b/include/async/post-ack.hpp @@ -308,7 +308,7 @@ struct post_ack_agent { void start() { assert(agnt_->mech_); - auto seq = agnt_->poll_seq_++; + auto seq = agnt_->poll_seq_; { frg::unique_lock lock(agnt_->mech_->mutex_); @@ -333,13 +333,17 @@ struct post_ack_agent { } } + if(nd) + ++agnt_->poll_seq_; execution::set_value(receiver_, post_ack_handle{agnt_->mech_, nd}); } private: void complete() override { - if(cobs_.try_reset()) + if(cobs_.try_reset()) { + ++agnt_->poll_seq_; execution::set_value(receiver_, post_ack_handle{agnt_->mech_, nd}); + } } void complete_cancel() { @@ -353,10 +357,12 @@ struct post_ack_agent { } } - if(nd) + if(nd) { + ++agnt_->poll_seq_; execution::set_value(receiver_, post_ack_handle{agnt_->mech_, nd}); - else + }else{ execution::set_value(receiver_, post_ack_handle{}); + } } post_ack_agent *agnt_;