You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/09/18 03:10:00 UTC

svn commit: r1386946 - in /incubator/mesos/trunk/src/slave: cgroups_isolation_module.cpp cgroups_isolation_module.hpp

Author: benh
Date: Tue Sep 18 01:09:59 2012
New Revision: 1386946

URL: http://svn.apache.org/viewvc?rev=1386946&view=rev
Log:
Fixing memory leak in cgroups isolation module.

Modified:
    incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp
    incubator/mesos/trunk/src/slave/cgroups_isolation_module.hpp

Modified: incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp?rev=1386946&r1=1386945&r2=1386946&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp (original)
+++ incubator/mesos/trunk/src/slave/cgroups_isolation_module.cpp Tue Sep 18 01:09:59 2012
@@ -253,17 +253,23 @@ void CgroupsIsolationModule::launchExecu
             << " in cgroup " << getCgroupName(frameworkId, executorId);
 
   // First fetch the executor.
-  launcher::ExecutorLauncher* launcher = createExecutorLauncher(frameworkId,
-                                                                frameworkInfo,
-                                                                executorInfo,
-                                                                directory);
+  launcher::ExecutorLauncher launcher(
+      frameworkId,
+      executorInfo.executor_id(),
+      executorInfo.command(),
+      frameworkInfo.user(),
+      directory,
+      slave,
+      flags.frameworks_home,
+      flags.hadoop_home,
+      !local,
+      flags.switch_user,
+      "");
 
-  if (launcher->setup() < 0) {
+  if (launcher.setup() < 0) {
     LOG(ERROR) << "Error setting up executor " << executorId
                << " for framework " << frameworkId;
 
-    delete launcher;
-
     unregisterCgroupInfo(frameworkId, executorId);
 
     LOG(INFO) << "Telling slave of lost executor " << executorId
@@ -372,8 +378,8 @@ void CgroupsIsolationModule::launchExecu
                  << ": " << assign.error();
     }
 
-    // Now launch the executor.
-    launcher->launch();
+    // Now launch the executor (this function should not return).
+    launcher.launch();
   }
 }
 
@@ -483,27 +489,6 @@ void CgroupsIsolationModule::processExit
 }
 
 
-launcher::ExecutorLauncher* CgroupsIsolationModule::createExecutorLauncher(
-    const FrameworkID& frameworkId,
-    const FrameworkInfo& frameworkInfo,
-    const ExecutorInfo& executorInfo,
-    const std::string& directory)
-{
-  return new launcher::ExecutorLauncher(
-      frameworkId,
-      executorInfo.executor_id(),
-      executorInfo.command(),
-      frameworkInfo.user(),
-      directory,
-      slave,
-      flags.frameworks_home,
-      flags.hadoop_home,
-      !local,
-      flags.switch_user,
-      "");
-}
-
-
 Try<bool> CgroupsIsolationModule::cpusChanged(
     const FrameworkID& frameworkId,
     const ExecutorID& executorId,

Modified: incubator/mesos/trunk/src/slave/cgroups_isolation_module.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/cgroups_isolation_module.hpp?rev=1386946&r1=1386945&r2=1386946&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/cgroups_isolation_module.hpp (original)
+++ incubator/mesos/trunk/src/slave/cgroups_isolation_module.hpp Tue Sep 18 01:09:59 2012
@@ -92,16 +92,6 @@ private:
     process::Future<uint64_t> oomNotifier;
   };
 
-  // Main method executed after a fork() to create a Launcher for launching an
-  // executor's process. The Launcher will chdir() to the child's working
-  // directory, fetch the executor, set environment varibles, switch user, etc,
-  // and finally exec() the executor process.
-  launcher::ExecutorLauncher* createExecutorLauncher(
-      const FrameworkID& frameworkId,
-      const FrameworkInfo& frameworkInfo,
-      const ExecutorInfo& executorInfo,
-      const std::string& directory);
-
   // The callback which will be invoked when "cpus" resource has changed.
   // @param   frameworkId   The id of the given framework.
   // @param   executorId    The id of the given executor.