diff --git a/src/CraneCtld/CtldGrpcServer.cpp b/src/CraneCtld/CtldGrpcServer.cpp index 2449741e3..7bbc072a3 100644 --- a/src/CraneCtld/CtldGrpcServer.cpp +++ b/src/CraneCtld/CtldGrpcServer.cpp @@ -201,8 +201,14 @@ grpc::Status CraneCtldServiceImpl::ModifyTask( } } else if (request->attribute() == ModifyTaskRequest::Hold) { int64_t secs = request->hold_seconds(); + std::vector>> results; + results.reserve(request->task_ids().size()); for (auto task_id : request->task_ids()) { - err = g_task_scheduler->HoldReleaseTaskAsync(task_id, secs).get(); + results.emplace_back( + task_id, g_task_scheduler->HoldReleaseTaskAsync(task_id, secs)); + } + for (auto &[task_id, res] : results) { + err = res.get(); if (err == CraneErr::kOk) { response->add_modified_tasks(task_id); } else if (err == CraneErr::kNonExistent) {