From 6d484db9b293aac4b8bd790eb7aead3a806f8c7b Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Fri, 4 Oct 2024 13:52:55 +0200 Subject: Enable cppcoreguidelines-* checks. --- .../execution_service/bytestream_server.cpp | 2 +- .../execution_service/execution_server.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/buildtool/execution_api/execution_service') diff --git a/src/buildtool/execution_api/execution_service/bytestream_server.cpp b/src/buildtool/execution_api/execution_service/bytestream_server.cpp index 1740c1f1..7d2bd48a 100644 --- a/src/buildtool/execution_api/execution_service/bytestream_server.cpp +++ b/src/buildtool/execution_api/execution_service/bytestream_server.cpp @@ -138,7 +138,7 @@ auto BytestreamServiceImpl::Write( auto tmp = tmp_dir->GetPath() / write_digest->hash(); { std::ofstream stream{tmp, std::ios::binary}; - do { + do { // NOLINT(cppcoreguidelines-avoid-do-while) if (not stream.good()) { auto const str = fmt::format("Failed to write data for {}", write_digest->hash()); diff --git a/src/buildtool/execution_api/execution_service/execution_server.cpp b/src/buildtool/execution_api/execution_service/execution_server.cpp index cbf61edd..6f77ba3f 100644 --- a/src/buildtool/execution_api/execution_service/execution_server.cpp +++ b/src/buildtool/execution_api/execution_service/execution_server.cpp @@ -262,17 +262,17 @@ auto ExecutionServiceImpl::WaitExecution( return ::grpc::Status{::grpc::StatusCode::INVALID_ARGUMENT, str}; } logger_.Emit(LogLevel::Trace, "WaitExecution: {}", hash); - std::optional<::google::longrunning::Operation> op; - do { - op = op_cache_.Query(hash); - if (not op) { - auto const str = fmt::format( - "Executing action {} not found in internal cache.", hash); - logger_.Emit(LogLevel::Error, "{}", str); - return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; - } + auto op = op_cache_.Query(hash); + while (op and not op->done()) { std::this_thread::sleep_for(std::chrono::seconds(1)); - } while (not op->done()); + op = op_cache_.Query(hash); + } + if (not op) { + auto const str = fmt::format( + "Executing action {} not found in internal cache.", hash); + logger_.Emit(LogLevel::Error, "{}", str); + return ::grpc::Status{grpc::StatusCode::INTERNAL, str}; + } writer->Write(*op); logger_.Emit(LogLevel::Trace, "Finished WaitExecution {}", hash); return ::grpc::Status::OK; -- cgit v1.2.3