You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by nn...@apache.org on 2014/10/09 22:23:09 UTC

git commit: Disallowed duplicate module names.

Repository: mesos
Updated Branches:
  refs/heads/master c96ba8f60 -> 700defe30


Disallowed duplicate module names.

Module manager should return error on encountering a duplicate module
name (i.e. if a module with the same name has already been loaded).

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


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

Branch: refs/heads/master
Commit: 700defe30b6f4b32dd40d371392b2237863737e6
Parents: c96ba8f
Author: Kapil Arya <ka...@mesosphere.io>
Authored: Thu Oct 9 13:03:01 2014 -0700
Committer: Niklas Q. Nielsen <ni...@mesosphere.io>
Committed: Thu Oct 9 13:03:01 2014 -0700

----------------------------------------------------------------------
 src/module/manager.cpp     |  4 ++++
 src/tests/module_tests.cpp | 19 +++++++++++++++++++
 2 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/700defe3/src/module/manager.cpp
----------------------------------------------------------------------
diff --git a/src/module/manager.cpp b/src/module/manager.cpp
index e2a9478..265f934 100644
--- a/src/module/manager.cpp
+++ b/src/module/manager.cpp
@@ -188,6 +188,10 @@ Try<Nothing> ModuleManager::load(const Modules& modules)
 
     // Load module manifests.
     foreach (const string& moduleName, library.modules()) {
+      // Check for possible duplicate module names.
+      if (moduleBases.contains(moduleName)) {
+        return Error("Error loading duplicate module '" + moduleName + "'");
+      }
       Try<void*> symbol =  dynamicLibrary->loadSymbol(moduleName);
       if (symbol.isError()) {
         return Error(

http://git-wip-us.apache.org/repos/asf/mesos/blob/700defe3/src/tests/module_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/module_tests.cpp b/src/tests/module_tests.cpp
index 6f9ee33..5a902e6 100644
--- a/src/tests/module_tests.cpp
+++ b/src/tests/module_tests.cpp
@@ -167,6 +167,25 @@ TEST_F(ModuleTest, NonModuleLibrary)
 }
 
 
+// Test that loading a duplicate module fails.
+TEST_F(ModuleTest, DuplicateModule)
+{
+  const string libraryName = "examplemodule";
+  const string moduleName = "org_apache_mesos_TestModule";
+
+  Modules modules = getModules(libraryName, moduleName);
+
+  // Add duplicate module.
+  Modules::Library* library = modules.add_libraries();
+  library->set_path(getLibraryPath(libraryName));
+  library->add_modules(moduleName);
+
+  EXPECT_ERROR(ModuleManager::load(modules));
+
+  ModuleManager::unloadAll();
+}
+
+
 // NOTE: We expect to pass 'version' which will outlive this function
 // since we set it to the external module's 'mesosVersion'.
 static void updateModuleLibraryVersion(