aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/target.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-07-17 17:17:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-07-17 17:17:55 +0200
commit4ca5a5bc2991438602d3b1fdb56b91d2b425c52d (patch)
treeb9a2f6f801031af9299bfc45095eac1eb3ceb495 /libbuild2/target.ixx
parentab4a9ef42e8f1070dcb5d783a5afccd2f685e86d (diff)
Fix race in path/mtime assignment and file_rule::match()
Diffstat (limited to 'libbuild2/target.ixx')
-rw-r--r--libbuild2/target.ixx15
1 files changed, 15 insertions, 0 deletions
diff --git a/libbuild2/target.ixx b/libbuild2/target.ixx
index 3d92c78..94c54c0 100644
--- a/libbuild2/target.ixx
+++ b/libbuild2/target.ixx
@@ -582,6 +582,21 @@ namespace build2
return mtime_target::load_mtime (path ());
}
+ inline const path& path_target::
+ path_mtime (path_type p, timestamp mt) const
+ {
+ // Because we use the presence of mtime to indicate the special "trust me,
+ // this file exists" situation, the order in which we do things is
+ // important. In particular, the fallback file_rule::match() will skip
+ // assigning the path if there is a valid timestamp. As a result, with the
+ // wrong order we may end up in a situation where the rule is matched but
+ // the path is not assigned.
+ //
+ const path_type& r (path (move (p)));
+ mtime (mt);
+ return r;
+ }
+
// exe
//
inline auto exe::