From 9920e41e1372229c52f74151af5f1570f32a489c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Apr 2022 09:33:13 +0200 Subject: Cache "recipe is group_action" information, clear recipes after execution --- libbuild2/algorithm.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'libbuild2/algorithm.cxx') diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index 8ef88e4..287ab2e 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -1914,14 +1914,20 @@ namespace build2 ts = s.state = target_state::failed; } + // Clear the recipe to release any associated memory. Note that + // s.recipe_group_action may be used further (see, for example, + // group_state()) and should retain its value. + // + // + s.recipe = nullptr; + // Decrement the target count (see set_recipe() for details). // - if (a.inner ()) - { - recipe_function** f (s.recipe.target ()); - if (f == nullptr || *f != &group_action) - ctx.target_count.fetch_sub (1, memory_order_relaxed); - } + // Note that here we cannot rely on s.state being group because of the + // postponment logic (see excute_recipe() for details). + // + if (a.inner () && !s.recipe_group_action) + ctx.target_count.fetch_sub (1, memory_order_relaxed); // Decrement the task count (to count_executed) and wake up any threads // that might be waiting for this target. -- cgit v1.1