]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
dout: use DoutLocker rather than Mutex::Locker
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 14 Feb 2011 12:10:17 +0000 (04:10 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 14 Feb 2011 12:17:50 +0000 (04:17 -0800)
Use DoutLocker rather than Mutex::Locker, in preparation for making the
dout_lock a plain old pthread_mutex_t.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/common/debug.cc
src/common/debug.h
src/config.cc
src/test/TestDoutStreambuf.cc

index fe41cce42f6c91b00543c91eb484dd2c47605cf9..4b1a81ae50c8a4136556f7225be7ad8be0cb82ed 100644 (file)
@@ -46,7 +46,7 @@ void _dout_open_log(bool print_version)
 
 int dout_handle_daemonize()
 {
-  Mutex::Locker l(_dout_lock);
+  DoutLocker _dout_locker;
 
   if (_dout_need_open)
        _dout_open_log(true);
@@ -58,7 +58,7 @@ int dout_handle_daemonize()
 
 int dout_create_rank_symlink(int n)
 {
-  Mutex::Locker l(_dout_lock);
+  DoutLocker _dout_locker;
 
   if (_dout_need_open)
     _dout_open_log(true);
index cad73973392136007993990aaa90ce338312f3a6..2768fdf179dff5e8ab92f434f63b99a126e4aa5f 100644 (file)
@@ -34,6 +34,17 @@ extern int dout_handle_daemonize();
 
 extern int dout_create_rank_symlink(int n);
 
+class DoutLocker
+{
+public:
+  DoutLocker() {
+    _dout_lock.Lock();
+  }
+  ~DoutLocker() {
+    _dout_lock.Unlock();
+  }
+};
+
 static inline void _dout_begin_line(signed int prio) {
   if (unlikely(_dout_need_open))
     _dout_open_log(true);
@@ -66,7 +77,7 @@ inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) {
   if (0) {\
     char __array[((v >= -1) && (v <= 200)) ? 0 : -1] __attribute__((unused)); \
   }\
-  Mutex::Locker _dout_locker(_dout_lock);\
+  DoutLocker __dout_locker; \
   _dout_begin_line(v); \
 
 #define dout(v) \
index 9dea8f2403951b904ac273311ddf16c6232cd567..57adc8fabcfa2e0e0dbed6da7b6a6383ea1d5b0d 100644 (file)
@@ -1103,7 +1103,7 @@ void parse_startup_config_options(std::vector<const char*>& args,
     // In the long term, it would be best to ensure that we read ceph.conf
     // before initializing dout(). For now, just force a reopen here with the
     // configuration we have just read.
-    Mutex::Locker l(_dout_lock);
+    DoutLocker _dout_locker;
     _dout_open_log(false);
   }
 
index ca6f7c58c1337aa4584de3366b46644e8984085d..769b9b9024b37b1f85869a6517d6d6d0467c2d69 100644 (file)
@@ -40,9 +40,10 @@ int main(int argc, const char **argv)
 
   DoutStreambuf<char> *dos = new DoutStreambuf<char>();
 
-  _dout_lock.Lock();
-  dos->read_global_config();
-  _dout_lock.Unlock();
+  {
+    DoutLocker _dout_locker;
+    dos->read_global_config();
+  }
   derr << "using configuration: " << dos->config_to_str() << dendl;
 
   std::ostream oss(dos);