From: Casey Bodley Date: Thu, 5 Jan 2017 21:06:45 +0000 (-0500) Subject: rgw: RGWAsyncRadosRequest drops notifier ref on cancel X-Git-Tag: v11.2.0~6^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0c0e5f2e7899882eb06075de0561c6c01b6d6159;p=ceph.git rgw: RGWAsyncRadosRequest drops notifier ref on cancel Signed-off-by: Casey Bodley (cherry picked from commit 1d586f76a11fed937fc7bb0f7cf6a44ca0506881) --- diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index 0f2ec78cb67..02f79290b16 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -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(); }