aboutsummaryrefslogtreecommitdiff
path: root/build2/target.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-10-25 10:56:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-10-25 10:56:22 +0200
commit8c637bf3530a92d8e22776e0dfda3df24f21e5d2 (patch)
tree61f35e3e9fbe39859cf1480c2a361edcf4a188e1 /build2/target.hxx
parentbcd4d3e18c93d5f132f871e78185bf743509dae6 (diff)
Fix race in rule synthesis logic
Diffstat (limited to 'build2/target.hxx')
-rw-r--r--build2/target.hxx18
1 files changed, 14 insertions, 4 deletions
diff --git a/build2/target.hxx b/build2/target.hxx
index d73a98c..fb1c68c 100644
--- a/build2/target.hxx
+++ b/build2/target.hxx
@@ -193,6 +193,10 @@ namespace build2
// special target_state::group state. You would normally also use the
// group_recipe for group members.
//
+ // Note that the group-member link-up can happen anywhere between the
+ // member creation and rule matching so reading the group before the
+ // member has been matched can be racy.
+ //
const target* group = nullptr;
// What has been described above is a "normal" group. That is, there is
@@ -320,14 +324,20 @@ namespace build2
bool
prerequisites (prerequisites_type&&) const;
- // Check if there are any prerequisites, taking into account group
- // prerequisites.
+ // Check if there are any prerequisites. Note that the group version may
+ // be racy (see target::group).
//
bool
has_prerequisites () const
{
- return !prerequisites ().empty () ||
- (group != nullptr && !group->prerequisites ().empty ());
+ return !prerequisites ().empty ();
+ }
+
+ bool
+ has_group_prerequisites () const
+ {
+ return has_prerequisites () ||
+ (group != nullptr && !group->has_prerequisites ());
}
private: