You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2013/09/27 20:57:55 UTC

git commit: Fixed slave's finalize() method to not throw segfault.

Updated Branches:
  refs/heads/master fc970f205 -> c83dd941d


Fixed slave's finalize() method to not throw segfault.

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


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

Branch: refs/heads/master
Commit: c83dd941db43dfb9d7e9e0270734827abe419836
Parents: fc970f2
Author: Vinod Kone <vi...@twitter.com>
Authored: Wed Sep 11 20:24:06 2013 -0700
Committer: Vinod Kone <vi...@twitter.com>
Committed: Fri Sep 27 11:53:37 2013 -0700

----------------------------------------------------------------------
 src/slave/slave.cpp | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c83dd941/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 21b57f9..0ad4576 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -453,7 +453,9 @@ void Slave::finalize()
 {
   LOG(INFO) << "Slave terminating";
 
-  foreachkey (const FrameworkID& frameworkId, frameworks) {
+  // NOTE: We use 'frameworks.keys()' here because 'shutdownFramework'
+  // can potentially remove a framework from 'frameworks'.
+  foreach (const FrameworkID& frameworkId, frameworks.keys()) {
     // TODO(benh): Because a shut down isn't instantaneous (but has
     // a shut down/kill phases) we might not actually propogate all
     // the status updates appropriately here. Consider providing
@@ -512,7 +514,9 @@ void Slave::shutdown()
     // since it cannot reliably know when a framework has shut down.
     // A short-term fix could be to wait for a certain time for ACKs
     // and then shutdown.
-    foreachkey (const FrameworkID& frameworkId, utils::copy(frameworks)) {
+    // NOTE: We use 'frameworks.keys()' here because 'shutdownFramework'
+    // can potentially remove a framework from 'frameworks'.
+    foreach (const FrameworkID& frameworkId, frameworks.keys()) {
       shutdownFramework(frameworkId);
     }
   }
@@ -1197,7 +1201,10 @@ void Slave::shutdownFramework(const FrameworkID& frameworkId)
       // NOTE: If there are no executors but 'pending' tasks, the
       // framework will be removed and all its tasks are appropriately
       // handled in '_runTask()'.
-      foreachvalue (Executor* executor, utils::copy(framework->executors)) {
+      // NOTE: We use 'executors.keys()' here because 'shutdownExecutor'
+      // and 'removeExecutor' can remove an executor from 'executors'.
+      foreach (const ExecutorID& executorId, framework->executors.keys()) {
+        Executor* executor = framework->executors[executorId];
         CHECK(executor->state == Executor::REGISTERING ||
               executor->state == Executor::RUNNING ||
               executor->state == Executor::TERMINATING ||