From: Colin Patrick McCabe Date: Mon, 14 Feb 2011 12:10:17 +0000 (-0800) Subject: dout: use DoutLocker rather than Mutex::Locker X-Git-Tag: v0.25~122^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=db188f0ccf196a25c1343f19b45ba4940a34587e;p=ceph.git dout: use DoutLocker rather than Mutex::Locker Use DoutLocker rather than Mutex::Locker, in preparation for making the dout_lock a plain old pthread_mutex_t. Signed-off-by: Colin McCabe --- diff --git a/src/common/debug.cc b/src/common/debug.cc index fe41cce42f6c..4b1a81ae50c8 100644 --- a/src/common/debug.cc +++ b/src/common/debug.cc @@ -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); diff --git a/src/common/debug.h b/src/common/debug.h index cad739733921..2768fdf179df 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -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) \ diff --git a/src/config.cc b/src/config.cc index 9dea8f240395..57adc8fabcfa 100644 --- a/src/config.cc +++ b/src/config.cc @@ -1103,7 +1103,7 @@ void parse_startup_config_options(std::vector& 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); } diff --git a/src/test/TestDoutStreambuf.cc b/src/test/TestDoutStreambuf.cc index ca6f7c58c133..769b9b9024b3 100644 --- a/src/test/TestDoutStreambuf.cc +++ b/src/test/TestDoutStreambuf.cc @@ -40,9 +40,10 @@ int main(int argc, const char **argv) DoutStreambuf *dos = new DoutStreambuf(); - _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);