diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-06-28 15:53:52 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-06-28 18:47:34 +0200 |
commit | f0d2d5d789760fb5f097bc9c5e71633ed0da205c (patch) | |
tree | 01ae245a01c3cf83aa42a1c26f9071cf759e795e /src | |
parent | fa15ce2549c378412b77f4297a1dc25932cc1418 (diff) | |
download | justbuild-f0d2d5d789760fb5f097bc9c5e71633ed0da205c.tar.gz |
just-mr: lock garbage collection
just-mr accesses the CAS at several occations, most importantly,
the generated multi-repository configuration is written there. In
particular, when used as a launcher, it needs to keep that file in
its location as the path is passed to the exec of just.
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/just_mr/TARGETS | 1 | ||||
-rw-r--r-- | src/other_tools/just_mr/main.cpp | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS index 02876feb..9bd70659 100644 --- a/src/other_tools/just_mr/TARGETS +++ b/src/other_tools/just_mr/TARGETS @@ -19,6 +19,7 @@ , ["src/other_tools/just_mr/progress_reporting", "progress"] , ["src/other_tools/just_mr/progress_reporting", "statistics"] , ["src/other_tools/just_mr/progress_reporting", "progress_reporter"] + , ["src/buildtool/storage", "storage"] ] , "stage": ["src", "other_tools", "just_mr"] , "private-ldflags": diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp index 56ba4a18..e331a063 100644 --- a/src/other_tools/just_mr/main.cpp +++ b/src/other_tools/just_mr/main.cpp @@ -24,6 +24,7 @@ #include "src/buildtool/logging/log_sink_cmdline.hpp" #include "src/buildtool/logging/log_sink_file.hpp" #include "src/buildtool/main/version.hpp" +#include "src/buildtool/storage/garbage_collector.hpp" #include "src/other_tools/just_mr/cli.hpp" #include "src/other_tools/just_mr/exit_codes.hpp" #include "src/other_tools/just_mr/progress_reporting/progress.hpp" @@ -1276,9 +1277,14 @@ void DefaultReachableRepositories( bool supports_defines{false}; std::optional<std::filesystem::path> mr_config_path{std::nullopt}; + std::optional<LockFile> lock{}; if (subcommand and kKnownJustSubcommands.contains(*subcommand)) { // Read the config file if needed if (kKnownJustSubcommands.at(*subcommand).config) { + lock = GarbageCollector::SharedLock(); + if (not lock) { + return kExitGenericFailure; + } auto config = ReadConfiguration(config_file); use_config = true; @@ -1502,6 +1508,10 @@ auto main(int argc, char* argv[]) -> int { arguments.cmd == SubCommand::kJustSubCmd) { return CallJust(config_file, arguments, forward_build_root); } + auto lock = GarbageCollector::SharedLock(); + if (not lock) { + return kExitGenericFailure; + } // The remaining options all need the config file auto config = ReadConfiguration(config_file); |