From 9a23629ff179c16309c7cfdb898926be03e8b105 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Wed, 28 Aug 2024 13:25:31 +0200 Subject: just-mr maps: Properly check for missing values in map chain The root async map in a chain of calls should always be checked for missing value, which can happen if, e.g., a cycle happens or a thread gets killed by the system. Properly handle this by checking explicitly if a value has been posted. If not, check for cycles where it makes sense (for example, in the resolving of symlinks), otherwise report any pending map keys not yet processed. This is done for all just-mr commands working with async maps. --- src/other_tools/just_mr/fetch.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/other_tools/just_mr/fetch.cpp') diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp index d236b7e8..c1d65010 100644 --- a/src/other_tools/just_mr/fetch.cpp +++ b/src/other_tools/just_mr/fetch.cpp @@ -31,6 +31,7 @@ #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/buildtool/main/retry.hpp" +#include "src/buildtool/multithreading/async_map_utils.hpp" #include "src/buildtool/multithreading/task_system.hpp" #include "src/buildtool/serve_api/remote/config.hpp" #include "src/buildtool/serve_api/remote/serve_api.hpp" @@ -542,12 +543,15 @@ auto MultiRepoFetch(std::shared_ptr const& config, // do the fetch bool failed_archives{false}; + bool has_value_archives{false}; { TaskSystem ts{common_args.jobs}; archive_fetch_map.ConsumeAfterKeysReady( &ts, archives_to_fetch, - []([[maybe_unused]] auto const& values) {}, + [&has_value_archives]([[maybe_unused]] auto const& values) { + has_value_archives = true; + }, [&failed_archives, &multi_repository_tool_name](auto const& msg, bool fatal) { Logger::Log(fatal ? LogLevel::Error : LogLevel::Warning, @@ -558,12 +562,15 @@ auto MultiRepoFetch(std::shared_ptr const& config, }); } bool failed_git_trees{false}; + bool has_value_trees{false}; { TaskSystem ts{common_args.jobs}; git_tree_fetch_map.ConsumeAfterKeysReady( &ts, git_trees_to_fetch, - []([[maybe_unused]] auto const& values) {}, + [&has_value_trees]([[maybe_unused]] auto const& values) { + has_value_trees = true; + }, [&failed_git_trees, &multi_repository_tool_name](auto const& msg, bool fatal) { Logger::Log(fatal ? LogLevel::Error : LogLevel::Warning, @@ -582,6 +589,13 @@ auto MultiRepoFetch(std::shared_ptr const& config, if (failed_archives or failed_git_trees) { return kExitFetchError; } + if (not has_value_archives or not has_value_trees) { + DetectAndReportPending( + "fetch archives", archive_fetch_map, kArchiveContentPrinter); + DetectAndReportPending( + "fetch trees", git_tree_fetch_map, kGitTreeInfoPrinter); + return kExitFetchError; + } // report success Logger::Log(LogLevel::Info, "Fetch completed"); return kExitSuccess; -- cgit v1.2.3