]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/PluginRegistry: Mutex -> ceph::mutex
authorSage Weil <sage@redhat.com>
Tue, 16 Oct 2018 14:32:22 +0000 (09:32 -0500)
committerKefu Chai <kchai@redhat.com>
Wed, 21 Nov 2018 03:56:32 +0000 (11:56 +0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/PluginRegistry.cc
src/common/PluginRegistry.h
src/test/compressor/test_compression.cc

index fd937df0a6ef2f6b0ce4c7f2fa45747d01bb73aa..2cb7fcee8db2809dead618e7d10ffa319e4d90b4 100644 (file)
@@ -36,7 +36,6 @@
 
 PluginRegistry::PluginRegistry(CephContext *cct) :
   cct(cct),
-  lock("PluginRegistry::lock"),
   loading(false),
   disable_dlclose(false)
 {
@@ -62,7 +61,7 @@ PluginRegistry::~PluginRegistry()
 
 int PluginRegistry::remove(const std::string& type, const std::string& name)
 {
-  ceph_assert(lock.is_locked());
+  ceph_assert(ceph_mutex_is_locked(lock));
 
   std::map<std::string,std::map<std::string,Plugin*> >::iterator i =
     plugins.find(type);
@@ -87,7 +86,7 @@ int PluginRegistry::add(const std::string& type,
                        const std::string& name,
                        Plugin* plugin)
 {
-  ceph_assert(lock.is_locked());
+  ceph_assert(ceph_mutex_is_locked(lock));
   if (plugins.count(type) &&
       plugins[type].count(name)) {
     return -EEXIST;
@@ -101,7 +100,7 @@ int PluginRegistry::add(const std::string& type,
 Plugin *PluginRegistry::get_with_load(const std::string& type,
           const std::string& name)
 {
-  std::lock_guard<Mutex> l(lock);
+  std::lock_guard l(lock);
   Plugin* ret = get(type, name);
   if (!ret) {
     int err = load(type, name);
@@ -114,7 +113,7 @@ Plugin *PluginRegistry::get_with_load(const std::string& type,
 Plugin *PluginRegistry::get(const std::string& type,
                            const std::string& name)
 {
-  ceph_assert(lock.is_locked());
+  ceph_assert(ceph_mutex_is_locked(lock));
   Plugin *ret = 0;
 
   std::map<std::string,Plugin*>::iterator j;
@@ -136,7 +135,7 @@ Plugin *PluginRegistry::get(const std::string& type,
 int PluginRegistry::load(const std::string &type,
                         const std::string &name)
 {
-  ceph_assert(lock.is_locked());
+  ceph_assert(ceph_mutex_is_locked(lock));
   ldout(cct, 1) << __func__ << " " << type << " " << name << dendl;
 
   // std::string fname = cct->_conf->plugin_dir + "/" + type + "/" PLUGIN_PREFIX
@@ -218,7 +217,7 @@ int ErasureCodePluginRegistry::preload(const std::string &plugins,
                                       const std::string &directory,
                                       ostream &ss)
 {
-  std::lock_guard<Mutex> l(lock);
+  std::lock_guard l(lock);
   list<string> plugins_list;
   get_str_list(plugins, plugins_list);
   for (list<string>::iterator i = plugins_list.begin();
index 4faa2455500e0e24789f445fdeb0a489d2f11150..5a092def7c5e458ad34450c2088371d544a2f4b3 100644 (file)
@@ -19,7 +19,7 @@
 #define CEPH_COMMON_PLUGINREGISTRY_H
 
 #include <map>
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
 
 class CephContext;
 
@@ -44,7 +44,7 @@ namespace ceph {
   class PluginRegistry {
   public:
     CephContext *cct;
-    Mutex lock;
+    ceph::mutex lock = ceph::make_mutex("PluginRegistery::lock");
     bool loading;
     bool disable_dlclose;
     std::map<std::string,std::map<std::string,Plugin*> > plugins;
index 48103ab996acad965947893858781a2d330ad828..2961b2bdb6bbf00859570ebbe0a0268ff7b92c76 100644 (file)
@@ -396,7 +396,7 @@ TEST(CompressionPlugin, all)
   EXPECT_EQ(0, factory->factory(&compressor, &ss));
   EXPECT_TRUE(compressor.get());
   {
-    Mutex::Locker l(reg->lock);
+    std::lock_guard l(reg->lock);
     EXPECT_EQ(-ENOENT, reg->remove("compressor", "does not exist"));
     EXPECT_EQ(0, reg->remove("compressor", "example"));
     EXPECT_EQ(0, reg->load("compressor", "example"));