From: Kefu Chai Date: Sun, 7 Jul 2019 04:34:19 +0000 (+0800) Subject: include/Context: s/Mutex/ceph::mutex/ X-Git-Tag: v15.1.0~1971^2~42 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2507fb64c35dfbc4dace874627b41ebeed59fd7c;p=ceph.git include/Context: s/Mutex/ceph::mutex/ Signed-off-by: Kefu Chai --- diff --git a/src/include/Context.h b/src/include/Context.h index 3d85283815a..8a1d8e8516b 100644 --- a/src/include/Context.h +++ b/src/include/Context.h @@ -24,7 +24,7 @@ #include #include "include/ceph_assert.h" -#include "common/Mutex.h" +#include "common/ceph_mutex.h" #define mydout(cct, v) lgeneric_subdout(cct, context, v) @@ -263,18 +263,19 @@ template class C_GatherBase { private: CephContext *cct; - int result; + int result = 0; ContextType *onfinish; #ifdef DEBUG_GATHER std::set waitfor; #endif - int sub_created_count; - int sub_existing_count; - mutable Mutex lock; - bool activated; + int sub_created_count = 0; + int sub_existing_count = 0; + mutable ceph::recursive_mutex lock = + ceph::make_recursive_mutex("C_GatherBase::lock"); // disable lockdep + bool activated = false; void sub_finish(ContextType* sub, int r) { - lock.Lock(); + lock.lock(); #ifdef DEBUG_GATHER ceph_assert(waitfor.count(sub)); waitfor.erase(sub); @@ -288,10 +289,10 @@ private: if (r < 0 && result == 0) result = r; if ((activated == false) || (sub_existing_count != 0)) { - lock.Unlock(); + lock.unlock(); return; } - lock.Unlock(); + lock.unlock(); delete_me(); } @@ -326,10 +327,7 @@ private: public: C_GatherBase(CephContext *cct_, ContextType *onfinish_) - : cct(cct_), result(0), onfinish(onfinish_), - sub_created_count(0), sub_existing_count(0), - lock("C_GatherBase::lock", true, false), //disable lockdep - activated(false) + : cct(cct_), onfinish(onfinish_) { mydout(cct,10) << "C_GatherBase " << this << ".new" << dendl; } @@ -337,23 +335,23 @@ public: mydout(cct,10) << "C_GatherBase " << this << ".delete" << dendl; } void set_finisher(ContextType *onfinish_) { - Mutex::Locker l(lock); + std::lock_guard l{lock}; ceph_assert(!onfinish); onfinish = onfinish_; } void activate() { - lock.Lock(); + lock.lock(); ceph_assert(activated == false); activated = true; if (sub_existing_count != 0) { - lock.Unlock(); + lock.unlock(); return; } - lock.Unlock(); + lock.unlock(); delete_me(); } ContextType *new_sub() { - Mutex::Locker l(lock); + std::lock_guard l{lock}; ceph_assert(activated == false); sub_created_count++; sub_existing_count++; @@ -366,12 +364,12 @@ public: } inline int get_sub_existing_count() const { - Mutex::Locker l(lock); + std::lock_guard l{lock}; return sub_existing_count; } inline int get_sub_created_count() const { - Mutex::Locker l(lock); + std::lock_guard l{lock}; return sub_created_count; } };