Renamed Hook to parent Hook in libprocess [1/2].

Review: https://reviews.apache.org/r/52017/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6a4a4f1a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6a4a4f1a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6a4a4f1a

Branch: refs/heads/master
Commit: 6a4a4f1a29301c1bac74042138f6bb3428adc9f3
Parents: 1db3bbb
Author: Joerg Schad <jo...@mesosphere.io>
Authored: Wed Sep 21 09:50:33 2016 -0700
Committer: Jie Yu <yujie....@gmail.com>
Committed: Wed Sep 21 09:50:33 2016 -0700

----------------------------------------------------------------------
 .../include/process/posix/subprocess.hpp          | 16 ++++++++--------
 .../include/process/subprocess_base.hpp           | 18 +++++++++---------
 3rdparty/libprocess/src/subprocess.cpp            |  9 +++++----
 3 files changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6a4a4f1a/3rdparty/libprocess/include/process/posix/subprocess.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/posix/subprocess.hpp 
b/3rdparty/libprocess/include/process/posix/subprocess.hpp
index d82db3c..a225919 100644
--- a/3rdparty/libprocess/include/process/posix/subprocess.hpp
+++ b/3rdparty/libprocess/include/process/posix/subprocess.hpp
@@ -305,7 +305,7 @@ inline Try<pid_t> cloneChild(
     const Option<map<string, string>>& environment,
     const Option<lambda::function<
         pid_t(const lambda::function<int()>&)>>& _clone,
-    const vector<Subprocess::Hook>& parent_hooks,
+    const vector<Subprocess::ParentHook>& parent_hooks,
     const vector<Subprocess::ChildHook>& child_hooks,
     const Watchdog watchdog,
     const InputFileDescriptors stdinfds,
@@ -403,15 +403,15 @@ inline Try<pid_t> cloneChild(
     os::close(pipes[0]);
 
     // Run the parent hooks.
-    foreach (const Subprocess::Hook& hook, parent_hooks) {
-      Try<Nothing> callback = hook.parent_callback(pid);
+    foreach (const Subprocess::ParentHook& hook, parent_hooks) {
+      Try<Nothing> parentSetup = hook.parent_setup(pid);
 
       // If the hook callback fails, we shouldn't proceed with the
       // execution and hence the child process should be killed.
-      if (callback.isError()) {
+      if (parentSetup.isError()) {
         LOG(WARNING)
-          << "Failed to execute Subprocess::Hook in parent for child '"
-          << pid << "': " << callback.error();
+          << "Failed to execute Subprocess::ParentHook in parent for child '"
+          << pid << "': " << parentSetup.error();
 
         os::close(pipes[1]);
 
@@ -425,8 +425,8 @@ inline Try<pid_t> cloneChild(
         ::kill(pid, SIGKILL);
 
         return Error(
-            "Failed to execute Subprocess::Hook in parent for child '" +
-            stringify(pid) + "': " + callback.error());
+            "Failed to execute Subprocess::ParentHook in parent for child '" +
+            stringify(pid) + "': " + parentSetup.error());
       }
     }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/6a4a4f1a/3rdparty/libprocess/include/process/subprocess_base.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/subprocess_base.hpp 
b/3rdparty/libprocess/include/process/subprocess_base.hpp
index 99b13c6..69d12ce 100644
--- a/3rdparty/libprocess/include/process/subprocess_base.hpp
+++ b/3rdparty/libprocess/include/process/subprocess_base.hpp
@@ -53,7 +53,7 @@ class Subprocess
 {
 public:
   // Forward declarations.
-  struct Hook;
+  struct ParentHook;
   class ChildHook;
 
   /**
@@ -143,7 +143,7 @@ public:
         const Option<std::map<std::string, std::string>>& environment,
         const Option<lambda::function<
             pid_t(const lambda::function<int()>&)>>& clone,
-        const std::vector<Subprocess::Hook>& parent_hooks,
+        const std::vector<Subprocess::ParentHook>& parent_hooks,
         const std::vector<Subprocess::ChildHook>& child_hooks,
         const Watchdog watchdog);
 
@@ -166,11 +166,11 @@ public:
   /**
    * A hook can be passed to a `subprocess` call. It provides a way to
    * inject dynamic implementation behavior between the clone and exec
-   * calls in the implementation of `subprocess`.
+   * calls in the parent process.
    */
-  struct Hook
+  struct ParentHook
   {
-    Hook(const lambda::function<Try<Nothing>(pid_t)>& _parent_callback);
+    ParentHook(const lambda::function<Try<Nothing>(pid_t)>& _parent_setup);
 
     /**
      * The callback that must be specified for execution after the
@@ -179,7 +179,7 @@ public:
      * initialization to add tracking or modify execution state of
      * the child before it executes the new process.
      */
-    const lambda::function<Try<Nothing>(pid_t)> parent_callback;
+    const lambda::function<Try<Nothing>(pid_t)> parent_setup;
 
     friend class Subprocess;
   };
@@ -292,7 +292,7 @@ private:
       const Option<std::map<std::string, std::string>>& environment,
       const Option<lambda::function<
           pid_t(const lambda::function<int()>&)>>& clone,
-      const std::vector<Subprocess::Hook>& parent_hooks,
+      const std::vector<Subprocess::ParentHook>& parent_hooks,
       const std::vector<Subprocess::ChildHook>& child_hooks,
       const Watchdog watchdog);
 
@@ -375,7 +375,7 @@ Try<Subprocess> subprocess(
     const Option<std::map<std::string, std::string>>& environment = None(),
     const Option<lambda::function<
         pid_t(const lambda::function<int()>&)>>& clone = None(),
-    const std::vector<Subprocess::Hook>& parent_hooks = {},
+    const std::vector<Subprocess::ParentHook>& parent_hooks = {},
     const std::vector<Subprocess::ChildHook>& child_hooks = {},
     const Watchdog watchdog = NO_MONITOR);
 
@@ -414,7 +414,7 @@ inline Try<Subprocess> subprocess(
     const Option<std::map<std::string, std::string>>& environment = None(),
     const Option<lambda::function<
         pid_t(const lambda::function<int()>&)>>& clone = None(),
-    const std::vector<Subprocess::Hook>& parent_hooks = {},
+    const std::vector<Subprocess::ParentHook>& parent_hooks = {},
     const std::vector<Subprocess::ChildHook>& child_hooks = {},
     const Watchdog watchdog = NO_MONITOR)
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/6a4a4f1a/3rdparty/libprocess/src/subprocess.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/subprocess.cpp 
b/3rdparty/libprocess/src/subprocess.cpp
index ce5c88f..123f800 100644
--- a/3rdparty/libprocess/src/subprocess.cpp
+++ b/3rdparty/libprocess/src/subprocess.cpp
@@ -49,9 +49,9 @@ using InputFileDescriptors = 
Subprocess::IO::InputFileDescriptors;
 using OutputFileDescriptors = Subprocess::IO::OutputFileDescriptors;
 
 
-Subprocess::Hook::Hook(
-    const lambda::function<Try<Nothing>(pid_t)>& _parent_callback)
-  : parent_callback(_parent_callback) {}
+Subprocess::ParentHook::ParentHook(
+    const lambda::function<Try<Nothing>(pid_t)>& _parent_setup)
+  : parent_setup(_parent_setup) {}
 
 
 Subprocess::ChildHook::ChildHook(
@@ -128,7 +128,7 @@ Try<Subprocess> subprocess(
     const Option<map<string, string>>& environment,
     const Option<lambda::function<
         pid_t(const lambda::function<int()>&)>>& _clone,
-    const vector<Subprocess::Hook>& parent_hooks,
+    const vector<Subprocess::ParentHook>& parent_hooks,
     const vector<Subprocess::ChildHook>& child_hooks,
     const Watchdog watchdog)
 {
@@ -218,6 +218,7 @@ Try<Subprocess> subprocess(
 
     process.data->pid = pid.get();
 #else
+    // TODO(joerg84): Consider using the childHooks and parentHooks here.
     Try<PROCESS_INFORMATION> processInformation = internal::createChildProcess(
         path, argv, environment, stdinfds, stdoutfds, stderrfds);
 

Reply via email to