]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: RGWAsyncRadosRequest drops notifier ref on cancel
authorCasey Bodley <cbodley@redhat.com>
Thu, 5 Jan 2017 21:06:45 +0000 (16:06 -0500)
committerCasey Bodley <cbodley@redhat.com>
Mon, 16 Jan 2017 18:54:09 +0000 (13:54 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 1d586f76a11fed937fc7bb0f7cf6a44ca0506881)

src/rgw/rgw_cr_rados.h

index 0f2ec78cb67ff77e7087d952ce58c795cc3e083e..02f79290b163b6f7c218ee69d6a46d5e18de3acf 100644 (file)
@@ -12,19 +12,18 @@ class RGWAsyncRadosRequest : public RefCountedObject {
 
   int retcode;
 
-  bool done;
-
   Mutex lock;
 
 protected:
   virtual int _send_request() = 0;
 public:
   RGWAsyncRadosRequest(RGWCoroutine *_caller, RGWAioCompletionNotifier *_cn) : caller(_caller), notifier(_cn), retcode(0),
-                                                                               done(false), lock("RGWAsyncRadosRequest::lock") {
-    notifier->get();
+                                                                               lock("RGWAsyncRadosRequest::lock") {
   }
   virtual ~RGWAsyncRadosRequest() {
-    notifier->put();
+    if (notifier) {
+      notifier->put();
+    }
   }
 
   void send_request() {
@@ -32,8 +31,9 @@ public:
     retcode = _send_request();
     {
       Mutex::Locker l(lock);
-      if (!done) {
-        notifier->cb();
+      if (notifier) {
+        notifier->cb(); // drops its own ref
+        notifier = nullptr;
       }
     }
     put();
@@ -44,7 +44,11 @@ public:
   void finish() {
     {
       Mutex::Locker l(lock);
-      done = true;
+      if (notifier) {
+        // we won't call notifier->cb() to drop its ref, so drop it here
+        notifier->put();
+        notifier = nullptr;
+      }
     }
     put();
   }