]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/common/PluginRegistry.cc
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / common / PluginRegistry.cc
index 2cb7fcee8db2809dead618e7d10ffa319e4d90b4..dd85d64fda0ec226ad0ca07b51cf1d239d8d0ec8 100644 (file)
 #include "common/ceph_context.h"
 #include "common/errno.h"
 #include "common/debug.h"
-
-#include <dlfcn.h>
+#include "include/dlfcn_compat.h"
 
 #define PLUGIN_PREFIX "libceph_"
-#ifdef __APPLE__
-#define PLUGIN_SUFFIX ".dylib"
-#else
-#define PLUGIN_SUFFIX ".so"
-#endif
+#define PLUGIN_SUFFIX SHARED_LIB_SUFFIX
 #define PLUGIN_INIT_FUNCTION "__ceph_plugin_init"
 #define PLUGIN_VERSION_FUNCTION "__ceph_plugin_version"
 
 #define dout_subsys ceph_subsys_context
 
+using std::map;
+using std::string;
+
+namespace ceph {
+
 PluginRegistry::PluginRegistry(CephContext *cct) :
   cct(cct),
   loading(false),
@@ -138,17 +138,15 @@ int PluginRegistry::load(const std::string &type,
   ceph_assert(ceph_mutex_is_locked(lock));
   ldout(cct, 1) << __func__ << " " << type << " " << name << dendl;
 
-  // std::string fname = cct->_conf->plugin_dir + "/" + type + "/" PLUGIN_PREFIX
-  //  + name + PLUGIN_SUFFIX;
   std::string fname = cct->_conf.get_val<std::string>("plugin_dir") + "/" + type + "/" + PLUGIN_PREFIX
       + name + PLUGIN_SUFFIX;
   void *library = dlopen(fname.c_str(), RTLD_NOW);
   if (!library) {
     string err1(dlerror());
     // fall back to plugin_dir
-    std::string fname2 = cct->_conf.get_val<std::string>("plugin_dir") + "/" + PLUGIN_PREFIX +
+    fname = cct->_conf.get_val<std::string>("plugin_dir") + "/" + PLUGIN_PREFIX +
       name + PLUGIN_SUFFIX;
-    library = dlopen(fname2.c_str(), RTLD_NOW);
+    library = dlopen(fname.c_str(), RTLD_NOW);
     if (!library) {
       lderr(cct) << __func__
                 << " failed dlopen(): \""      << err1.c_str() 
@@ -211,6 +209,7 @@ int PluginRegistry::load(const std::string &type,
                << " loaded and registered" << dendl;
   return 0;
 }
+}
 
 /*
 int ErasureCodePluginRegistry::preload(const std::string &plugins,