You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2019/05/06 22:06:41 UTC

[mesos] 01/02: Fixed an issue where /__processes__ never returns a response.

This is an automated email from the ASF dual-hosted git repository.

bmahler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 52227a07bb56195fd2c695080746a583ad4c2c87
Author: Benjamin Mahler <bm...@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 1248364..a47b570 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::vector<JSON::Object>& objects) -> Response {
+      .then([](const std::vector<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);
+          }
         }
         return OK(array);
       });