]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/PluginRegistry: try $plugin_dir/$foo if $plugin_dir/$type/$foo fails
authorSage Weil <sage@redhat.com>
Thu, 30 Jun 2016 14:54:26 +0000 (10:54 -0400)
committerSage Weil <sage@redhat.com>
Thu, 30 Jun 2016 15:06:21 +0000 (11:06 -0400)
This is helpful for running out of a build dir, where e.g. cmake puts
stuff in lib/* and type separated into subdirs by type.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/PluginRegistry.cc

index fb02d4a45a5da851328ebbaf95ed946ee084085d..661df1c74e50f90ca0402e1313e2a2facf79dbe8 100644 (file)
@@ -142,9 +142,15 @@ int PluginRegistry::load(const std::string &type,
     + name + PLUGIN_SUFFIX;
   void *library = dlopen(fname.c_str(), RTLD_NOW);
   if (!library) {
-    lderr(cct) << __func__ << " failed dlopen(" << fname << "): "
-              << dlerror() << dendl;
-    return -EIO;
+    // fall back to plugin_dir
+    std::string fname2 = cct->_conf->plugin_dir + "/" + PLUGIN_PREFIX +
+      name + PLUGIN_SUFFIX;
+    library = dlopen(fname2.c_str(), RTLD_NOW);
+    if (!library) {
+      lderr(cct) << __func__ << " failed dlopen(" << fname << ") or dlopen("
+                << fname2 << "): " << dlerror() << dendl;
+      return -EIO;
+    }
   }
 
   const char * (*code_version)() =