Blame SOURCES/0017-Throttle-added-pending_error-method-to-SimpleThrottl.patch

545b23
From 91faeff9492b3b4d014863b424329f138efdb185 Mon Sep 17 00:00:00 2001
545b23
From: Jason Dillaman <dillaman@redhat.com>
545b23
Date: Wed, 8 Apr 2015 21:48:21 -0400
545b23
Subject: [PATCH 17/22] Throttle: added pending_error method to SimpleThrottle
545b23
545b23
Allow the client of SimpleThrottle to detect an async error
545b23
so that it can exit early.
545b23
545b23
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
545b23
(cherry picked from commit b88b88c5df91325fb713c2031a56bffe421268e0)
545b23
(cherry picked from commit c2ea7e85dcbca60e6ae09d4ef99d02834d02b2ed)
545b23
---
545b23
 src/common/Throttle.cc | 6 ++++++
545b23
 src/common/Throttle.h  | 3 ++-
545b23
 2 files changed, 8 insertions(+), 1 deletion(-)
545b23
545b23
diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc
545b23
index 026d731..5c68a1f 100644
545b23
--- a/src/common/Throttle.cc
545b23
+++ b/src/common/Throttle.cc
545b23
@@ -267,6 +267,12 @@ void SimpleThrottle::end_op(int r)
545b23
   m_cond.Signal();
545b23
 }
545b23
 
545b23
+bool SimpleThrottle::pending_error() const
545b23
+{
545b23
+  Mutex::Locker l(m_lock);
545b23
+  return (m_ret < 0);
545b23
+}
545b23
+
545b23
 int SimpleThrottle::wait_for_ret()
545b23
 {
545b23
   Mutex::Locker l(m_lock);
545b23
diff --git a/src/common/Throttle.h b/src/common/Throttle.h
545b23
index 6d03988..b171e27 100644
545b23
--- a/src/common/Throttle.h
545b23
+++ b/src/common/Throttle.h
545b23
@@ -76,9 +76,10 @@ public:
545b23
   ~SimpleThrottle();
545b23
   void start_op();
545b23
   void end_op(int r);
545b23
+  bool pending_error() const;
545b23
   int wait_for_ret();
545b23
 private:
545b23
-  Mutex m_lock;
545b23
+  mutable Mutex m_lock;
545b23
   Cond m_cond;
545b23
   uint64_t m_max;
545b23
   uint64_t m_current;
545b23
-- 
545b23
2.1.0
545b23