aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/target.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-11-07 07:21:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-11-07 07:21:06 +0200
commit98c7247ff06decba8130e8aea67ea839d084d2dd (patch)
treefea6d2a7f5172c78992ccada6229db86cc1e10b2 /libbuild2/target.cxx
parenta8ff78d8b90d6f7a45c9586449986dadb65809c8 (diff)
Account for match options re-locking when checking if target is matched
Diffstat (limited to 'libbuild2/target.cxx')
-rw-r--r--libbuild2/target.cxx12
1 files changed, 8 insertions, 4 deletions
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.