]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/LogClient: Mutex -> ceph::mutex
authorSage Weil <sage@redhat.com>
Tue, 16 Oct 2018 14:14:20 +0000 (09:14 -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/LogClient.cc
src/common/LogClient.h

index 7ae871484668c61d8278de861703c31832df7525..951588ff44bf8b76827332d3df3d6a00ab84a95b 100644 (file)
@@ -100,7 +100,7 @@ static ostream& _prefix(std::ostream *_dout, LogChannel *lc) {
 }
 
 LogChannel::LogChannel(CephContext *cct, LogClient *lc, const string &channel)
-  : cct(cct), parent(lc), channel_lock("LogChannel::channel_lock"),
+  : cct(cct), parent(lc),
     log_channel(channel), log_to_syslog(false), log_to_monitors(false)
 {
 }
@@ -108,7 +108,7 @@ LogChannel::LogChannel(CephContext *cct, LogClient *lc, const string &channel)
 LogChannel::LogChannel(CephContext *cct, LogClient *lc,
                        const string &channel, const string &facility,
                        const string &prio)
-  : cct(cct), parent(lc), channel_lock("LogChannel::channel_lock"),
+  : cct(cct), parent(lc),
     log_channel(channel), log_prio(prio), syslog_facility(facility),
     log_to_syslog(false), log_to_monitors(false)
 {
@@ -117,7 +117,7 @@ LogChannel::LogChannel(CephContext *cct, LogClient *lc,
 LogClient::LogClient(CephContext *cct, Messenger *m, MonMap *mm,
                     enum logclient_flag_t flags)
   : cct(cct), messenger(m), monmap(mm), is_mon(flags & FLAG_MON),
-    log_lock("LogClient::log_lock"), last_log_sent(0), last_log(0)
+    last_log_sent(0), last_log(0)
 {
 }
 
@@ -212,7 +212,7 @@ void LogChannel::do_log(clog_type prio, std::stringstream& ss)
 
 void LogChannel::do_log(clog_type prio, const std::string& s)
 {
-  std::lock_guard<Mutex> l(channel_lock);
+  std::lock_guard l(channel_lock);
   if (CLOG_ERROR == prio) {
     ldout(cct,-1) << "log " << prio << " : " << s << dendl;
   } else {
@@ -250,7 +250,7 @@ void LogChannel::do_log(clog_type prio, const std::string& s)
 
 Message *LogClient::get_mon_log_message(bool flush)
 {
-  std::lock_guard<Mutex> l(log_lock);
+  std::lock_guard l(log_lock);
   if (flush) {
     if (log_queue.empty())
       return nullptr;
@@ -262,13 +262,13 @@ Message *LogClient::get_mon_log_message(bool flush)
 
 bool LogClient::are_pending()
 {
-  std::lock_guard<Mutex> l(log_lock);
+  std::lock_guard l(log_lock);
   return last_log > last_log_sent;
 }
 
 Message *LogClient::_get_mon_log_message()
 {
-  ceph_assert(log_lock.is_locked());
+  ceph_assert(ceph_mutex_is_locked(log_lock));
   if (log_queue.empty())
     return NULL;
 
@@ -314,7 +314,7 @@ Message *LogClient::_get_mon_log_message()
 
 void LogClient::_send_to_mon()
 {
-  ceph_assert(log_lock.is_locked());
+  ceph_assert(ceph_mutex_is_locked(log_lock));
   ceph_assert(is_mon);
   ceph_assert(messenger->get_myname().is_mon());
   ldout(cct,10) << __func__ << " log to self" << dendl;
@@ -324,7 +324,7 @@ void LogClient::_send_to_mon()
 
 version_t LogClient::queue(LogEntry &entry)
 {
-  std::lock_guard<Mutex> l(log_lock);
+  std::lock_guard l(log_lock);
   entry.seq = ++last_log;
   log_queue.push_back(entry);
 
@@ -337,7 +337,7 @@ version_t LogClient::queue(LogEntry &entry)
 
 uint64_t LogClient::get_next_seq()
 {
-  std::lock_guard<Mutex> l(log_lock);
+  std::lock_guard l(log_lock);
   return ++last_log;
 }
 
@@ -358,7 +358,7 @@ const EntityName& LogClient::get_myname()
 
 bool LogClient::handle_log_ack(MLogAck *m)
 {
-  std::lock_guard<Mutex> l(log_lock);
+  std::lock_guard l(log_lock);
   ldout(cct,10) << "handle_log_ack " << *m << dendl;
 
   version_t last = m->last;
index 2241f9cb062cd65cee9e94a62281dda8351b7a79..e138beac0b6e8c03169706004d1432653cb5eb94 100644 (file)
@@ -17,7 +17,7 @@
 
 #include <atomic>
 #include "common/LogEntry.h"
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
 #include "include/health.h"
 
 class LogClient;
@@ -192,7 +192,7 @@ public:
 private:
   CephContext *cct;
   LogClient *parent;
-  Mutex channel_lock;
+  ceph::mutex channel_lock = ceph::make_mutex("LogChannel::channel_lock");
   std::string log_channel;
   std::string log_prio;
   std::string syslog_facility;
@@ -262,7 +262,7 @@ private:
   Messenger *messenger;
   MonMap *monmap;
   bool is_mon;
-  Mutex log_lock;
+  ceph::mutex log_lock = ceph::make_mutex("LogClient::log_lock");
   version_t last_log_sent;
   version_t last_log;
   std::deque<LogEntry> log_queue;