From: Jason Dillaman Date: Thu, 9 Apr 2015 01:48:21 +0000 (-0400) Subject: Throttle: added pending_error method to SimpleThrottle X-Git-Tag: v0.94.3~59^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dbd4e293d7124c89a22148e8fa5f425a995c900c;p=ceph.git Throttle: added pending_error method to SimpleThrottle Allow the client of SimpleThrottle to detect an async error so that it can exit early. Signed-off-by: Jason Dillaman (cherry picked from commit b88b88c5df91325fb713c2031a56bffe421268e0) --- diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index 026d731e839b5..5c68a1fe4f3a7 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -267,6 +267,12 @@ void SimpleThrottle::end_op(int r) m_cond.Signal(); } +bool SimpleThrottle::pending_error() const +{ + Mutex::Locker l(m_lock); + return (m_ret < 0); +} + int SimpleThrottle::wait_for_ret() { Mutex::Locker l(m_lock); diff --git a/src/common/Throttle.h b/src/common/Throttle.h index 6d039888c633e..b171e27ed00f3 100644 --- a/src/common/Throttle.h +++ b/src/common/Throttle.h @@ -76,9 +76,10 @@ public: ~SimpleThrottle(); void start_op(); void end_op(int r); + bool pending_error() const; int wait_for_ret(); private: - Mutex m_lock; + mutable Mutex m_lock; Cond m_cond; uint64_t m_max; uint64_t m_current;