]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.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, 9 Jan 2017 16:30:50 +0000 (11:30 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_cr_rados.h

index 4079cf83c8a99f940a1fdd1ab9ebce8420594c90..fa8ac58241d5d960a9352b8cabd04387bbd180d8 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();
   }