From 63d1d6f8f4bb6db482b21e728245ebf9eee6b55f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 16 Feb 2018 11:30:41 +0200 Subject: Fix group link-up race --- build2/algorithm.ixx | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'build2/algorithm.ixx') diff --git a/build2/algorithm.ixx b/build2/algorithm.ixx index f0330f6..9b1df35 100644 --- a/build2/algorithm.ixx +++ b/build2/algorithm.ixx @@ -360,10 +360,10 @@ namespace build2 } group_view - resolve_group_members_impl (action, const target&, target_lock); + resolve_members_impl (action, const target&, target_lock); inline group_view - resolve_group_members (action a, const target& g) + resolve_members (action a, const target& g) { group_view r; @@ -386,7 +386,7 @@ namespace build2 // we can do, then unlock and return. // if (r.members == nullptr && l.offset != target::offset_executed) - r = resolve_group_members_impl (a, g, move (l)); + r = resolve_members_impl (a, g, move (l)); break; } @@ -398,6 +398,38 @@ namespace build2 } void + resolve_group_impl (action, const target&, target_lock); + + inline const target* + resolve_group (action a, const target& t) + { + if (a.outer ()) + a = a.inner_action (); + + switch (phase) + { + case run_phase::match: + { + // Grab a target lock to make sure the group state is synchronized. + // + target_lock l (lock_impl (a, t, scheduler::work_none)); + + // If the group is alrealy known or there is nothing else we can do, + // then unlock and return. + // + if (t.group == nullptr && l.offset < target::offset_tried) + resolve_group_impl (a, t, move (l)); + + break; + } + case run_phase::execute: break; + case run_phase::load: assert (false); + } + + return t.group; + } + + void match_prerequisites (action, target&, const scope*); void -- cgit v1.1