From 2fd0863c6a1689180e032681dd574810b7e83c5f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Apr 2017 19:48:16 +0200 Subject: Fix buildfile loading race --- build2/target.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'build2') diff --git a/build2/target.cxx b/build2/target.cxx index e1712b9..1922570 100644 --- a/build2/target.cxx +++ b/build2/target.cxx @@ -811,6 +811,18 @@ namespace build2 // phase_switch ps (run_phase::load); + // This is subtle: while we were fussing around another thread may + // have loaded the buildfile. So re-test now that we are in exclusive + // phase. + // + if (t == nullptr) + t = search_existing_target (pk); + + if (t != nullptr && !t->implied) + return t; + + // Ok, no luck, switch the scope. + // pair sp ( switch_scope (*s.rw ().root_scope (), out_base)); -- cgit v1.1