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


The following commit(s) were added to refs/heads/master by this push:
     new 06d8d43  Avoid double reaping race in the command executor.
06d8d43 is described below

commit 06d8d438063a06cf2f50c6bfb7392ebe2818fd20
Author: Benjamin Mahler <[email protected]>
AuthorDate: Mon Oct 21 19:19:58 2019 -0400

    Avoid double reaping race in the command executor.
    
    Previously, it was possible for the command executor to miss
    the exit status of the subprocess since it performs its own
    reap and doesn't use the Subprocess::status. See MESOS-10007.
    
    Review: https://reviews.apache.org/r/71652
---
 src/launcher/executor.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index d9b39e5..c1ba017 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -413,7 +413,7 @@ protected:
     delay(Seconds(1), self(), &Self::doReliableRegistration);
   }
 
-  static pid_t launchTaskSubprocess(
+  static Subprocess launchTaskSubprocess(
       const CommandInfo& command,
       const string& launcherDir,
       const Environment& environment,
@@ -563,7 +563,7 @@ protected:
       ABORT("Failed to launch task subprocess: " + s.error());
     }
 
-    return s->pid();
+    return *s;
   }
 
   void launch(const TaskInfo& task)
@@ -721,7 +721,7 @@ protected:
 
     LOG(INFO) << "Starting task " << taskId.get();
 
-    pid = launchTaskSubprocess(
+    Subprocess subprocess = launchTaskSubprocess(
         command,
         launcherDir,
         launchEnvironment,
@@ -735,6 +735,8 @@ protected:
         taskLaunchInfo,
         taskSupplementaryGroups);
 
+    pid = subprocess.pid();
+
     LOG(INFO) << "Forked command at " << pid.get();
 
     if (task.has_check()) {
@@ -799,7 +801,7 @@ protected:
     }
 
     // Monitor this process.
-    process::reap(pid.get())
+    subprocess.status()
       .onAny(defer(self(), &Self::reaped, pid.get(), lambda::_1));
 
     TaskStatus status = createTaskStatus(taskId.get(), TASK_RUNNING);

Reply via email to