]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Throttle: added pending_error method to SimpleThrottle
authorJason Dillaman <dillaman@redhat.com>
Thu, 9 Apr 2015 01:48:21 +0000 (21:48 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 24 Jul 2015 13:59:56 +0000 (09:59 -0400)
Allow the client of SimpleThrottle to detect an async error
so that it can exit early.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit b88b88c5df91325fb713c2031a56bffe421268e0)

src/common/Throttle.cc
src/common/Throttle.h

index 026d731e839b59a2ede30442602beb7710d43fce..5c68a1fe4f3a7aae7b5b2ee3343985d4e05fcd2c 100644 (file)
@@ -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);
index 6d039888c633e7dce8904498a4cc801d6b0fc693..b171e27ed00f3babd3642b8032e40b6f6d750819 100644 (file)
@@ -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;