Ensured that `Latch*` in exec, sched drivers are initialized.

In error code paths, this value was previously left uninitialized,
which might subsequently result in attempting to delete an
uninitialized pointer value.

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


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

Branch: refs/heads/master
Commit: aacc49e189508503e4c1509271302662aa53de27
Parents: 27a2fb8
Author: Neil Conway <neil.con...@gmail.com>
Authored: Tue Sep 20 18:01:30 2016 +0200
Committer: Michael Park <mp...@apache.org>
Committed: Tue Sep 20 19:57:55 2016 +0200

----------------------------------------------------------------------
 src/exec/exec.cpp   |  1 +
 src/sched/sched.cpp | 10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/aacc49e1/src/exec/exec.cpp
----------------------------------------------------------------------
diff --git a/src/exec/exec.cpp b/src/exec/exec.cpp
index c1cda5a..448069e 100644
--- a/src/exec/exec.cpp
+++ b/src/exec/exec.cpp
@@ -604,6 +604,7 @@ private:
 MesosExecutorDriver::MesosExecutorDriver(mesos::Executor* _executor)
   : executor(_executor),
     process(nullptr),
+    latch(nullptr),
     status(DRIVER_NOT_STARTED)
 {
   GOOGLE_PROTOBUF_VERIFY_VERSION;

http://git-wip-us.apache.org/repos/asf/mesos/blob/aacc49e1/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index 6a1a201..9d1b5ce 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -1690,7 +1690,11 @@ void MesosSchedulerDriver::initialize() {
     return;
   }
 
-  // Initialize libprocess.
+  // Initialize libprocess. NOTE: We need to ensure this happens
+  // before we invoke anything in libprocess. While libprocess will
+  // call `process::initialize` internally if needed, it will do so
+  // without passing any parameters; any subsequent calls to
+  // `process::initialize` (with non-empty arguments) will be ignored.
   process::initialize(schedulerId);
 
   if (process::address().ip.isLoopback()) {
@@ -1774,6 +1778,7 @@ MesosSchedulerDriver::MesosSchedulerDriver(
     framework(_framework),
     master(_master),
     process(nullptr),
+    latch(nullptr),
     status(DRIVER_NOT_STARTED),
     implicitAcknowlegements(true),
     credential(nullptr),
@@ -1793,6 +1798,7 @@ MesosSchedulerDriver::MesosSchedulerDriver(
     framework(_framework),
     master(_master),
     process(nullptr),
+    latch(nullptr),
     status(DRIVER_NOT_STARTED),
     implicitAcknowlegements(true),
     credential(new Credential(_credential)),
@@ -1812,6 +1818,7 @@ MesosSchedulerDriver::MesosSchedulerDriver(
     framework(_framework),
     master(_master),
     process(nullptr),
+    latch(nullptr),
     status(DRIVER_NOT_STARTED),
     implicitAcknowlegements(_implicitAcknowlegements),
     credential(nullptr),
@@ -1832,6 +1839,7 @@ MesosSchedulerDriver::MesosSchedulerDriver(
     framework(_framework),
     master(_master),
     process(nullptr),
+    latch(nullptr),
     status(DRIVER_NOT_STARTED),
     implicitAcknowlegements(_implicitAcknowlegements),
     credential(new Credential(_credential)),

Reply via email to