From 4ca5a5bc2991438602d3b1fdb56b91d2b425c52d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 17 Jul 2020 17:17:55 +0200 Subject: Fix race in path/mtime assignment and file_rule::match() --- libbuild2/cc/common.cxx | 24 +++++++----------------- libbuild2/cc/msvc.cxx | 8 ++------ 2 files changed, 9 insertions(+), 23 deletions(-) (limited to 'libbuild2/cc') diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx index e11dea2..f848003 100644 --- a/libbuild2/cc/common.cxx +++ b/libbuild2/cc/common.cxx @@ -651,25 +651,20 @@ namespace build2 else assert (find_adhoc_member (*s) == i); - i->mtime (mt); - i->path (move (f)); - // Presumably there is a DLL somewhere, we just don't know // where (and its possible we might have to look for one if we // decide we need to do rpath emulation for installed // libraries as well). We will represent this as empty path // but valid timestamp (aka "trust me, it's there"). // - s->mtime (mt); - s->path (empty_path); + i->path_mtime (move (f), mt); + s->path_mtime (path (), mt); } } else { insert_library (ctx, s, name, d, ld, se, exist, trace); - - s->mtime (mt); - s->path (move (f)); + s->path_mtime (move (f), mt); } } else if (!ext && tsys == "mingw32") @@ -687,9 +682,7 @@ namespace build2 if (mt != timestamp_nonexistent) { insert_library (ctx, s, name, d, ld, se, exist, trace); - - s->mtime (mt); - s->path (move (f)); + s->path_mtime (move (f), mt); } } } @@ -712,8 +705,7 @@ namespace build2 // as out trees. // insert_library (ctx, a, name, d, ld, ae, exist, trace); - a->mtime (mt); - a->path (move (f)); + a->path_mtime (move (f), mt); } } @@ -747,15 +739,13 @@ namespace build2 if (na && !r.first.empty ()) { insert_library (ctx, a, name, d, ld, nullopt, exist, trace); - a->mtime (timestamp_unreal); - a->path (empty_path); + a->path_mtime (path (), timestamp_unreal); } if (ns && !r.second.empty ()) { insert_library (ctx, s, name, d, ld, nullopt, exist, trace); - s->mtime (timestamp_unreal); - s->path (empty_path); + s->path_mtime (path (), timestamp_unreal); } // Only keep these .pc paths if we found anything via them. diff --git a/libbuild2/cc/msvc.cxx b/libbuild2/cc/msvc.cxx index 20239c7..8f0a853 100644 --- a/libbuild2/cc/msvc.cxx +++ b/libbuild2/cc/msvc.cxx @@ -528,10 +528,7 @@ namespace build2 // T* t; common::insert_library (p.scope->ctx, t, name, d, ld, e, exist, trace); - - t->mtime (mt); - t->path (move (f)); - + t->path_mtime (move (f), mt); return t; } @@ -603,8 +600,7 @@ namespace build2 // Presumably there is a DLL somewhere, we just don't know where. // - s->mtime (i->mtime ()); - s->path (path ()); + s->path_mtime (path (), i->mtime ()); } } -- cgit v1.1