This is an automated email from the ASF dual-hosted git repository. bmahler pushed a commit to branch 1.6.x in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 27d4a57cd67fecaa37b199d2d81e2bbba4e7d7d9 Author: Benjamin Mahler <bmah...@apache.org> AuthorDate: Fri May 3 15:51:31 2019 -0400 Fixed an issue where /__processes__ never returns a response. It's possible for /__processes__ to never return a response if a process is terminated after the /__processes__ handler dispatches to it, thus leading the Future to be abandoned. This patch ensures we ignore those cases, rather than wait forever. See MESOS-9766. Review: https://reviews.apache.org/r/70594 --- 3rdparty/libprocess/src/process.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp index c428714..259037d 100644 --- a/3rdparty/libprocess/src/process.cpp +++ b/3rdparty/libprocess/src/process.cpp @@ -3396,15 +3396,23 @@ Future<Response> ProcessManager::__processes__(const Request&) // high-priority set of events (i.e., mailbox). return dispatch( process->self(), - [process]() -> JSON::Object { - return *process; - }); + [process]() -> Option<JSON::Object> { + return Option<JSON::Object>(*process); + }) + // We must recover abandoned futures in case + // the process is terminated and the dispatch + // is dropped. + .recover([](const Future<Option<JSON::Object>>& f) { + return Option<JSON::Object>::none(); + }); }, process_manager->processes.values())) - .then([](const std::list<JSON::Object>& objects) -> Response { + .then([](const std::list<Option<JSON::Object>>& objects) -> Response { JSON::Array array; - foreach (const JSON::Object& object, objects) { - array.values.push_back(object); + foreach (const Option<JSON::Object>& object, objects) { + if (object.isSome()) { + array.values.push_back(object.get()); + } } return OK(array); });