From ab91d32c1b23ea92b988d5618db2938a8c5dc63f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 26 May 2023 07:22:40 +0200 Subject: Avoid group linkup deadlocks for dynamic and pattern-static members --- libbuild2/target.hxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libbuild2/target.hxx') diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index 3f73e63..c7b1131 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -380,9 +380,12 @@ namespace build2 // // 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. + // member has been matched can be racy. However, once the member is linked + // up to the group, this relationship is immutable. As a result, one can + // atomically query the current value to see if already linked up (can be + // used as an optimization, to avoid deadlocks, etc). // - const target* group = nullptr; + relaxed_atomic group = nullptr; // What has been described above is an "explicit" group. That is, there is // a dedicated target type that explicitly serves as a group and there is -- cgit v1.1