From 98c7247ff06decba8130e8aea67ea839d084d2dd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Nov 2023 07:21:06 +0200 Subject: Account for match options re-locking when checking if target is matched --- libbuild2/target.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'libbuild2/target.cxx') diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx index fb47b6d..b4c3968 100644 --- a/libbuild2/target.cxx +++ b/libbuild2/target.cxx @@ -1004,15 +1004,19 @@ namespace build2 case run_phase::load: break; case run_phase::match: { - // Similar logic to matched_state_impl(). + // Similar logic to target::matched(). // const opstate& s (state[action () /* inner */]); - // Note: already synchronized. - size_t c (s.task_count.load (memory_order_relaxed)); + // Note: use acquire for group_state(). + // + size_t c (s.task_count.load (memory_order_acquire)); size_t b (ctx.count_base ()); // Note: cannot do (c - b)! - if (c != (b + offset_applied) && c != (b + offset_executed)) + if (!(c == (b + offset_applied) || + c == (b + offset_executed) || + (c >= (b + offset_busy) && + s.match_extra.cur_options_.load (memory_order_relaxed) != 0))) break; } // Fall through. -- cgit v1.1