From 1d586f76a11fed937fc7bb0f7cf6a44ca0506881 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 5 Jan 2017 16:06:45 -0500 Subject: [PATCH] rgw: RGWAsyncRadosRequest drops notifier ref on cancel Signed-off-by: Casey Bodley --- src/rgw/rgw_cr_rados.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index 4079cf83c8a9..fa8ac58241d5 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(); } -- 2.47.3