Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw multisite: fix ref counting of completions #12841

Merged
merged 2 commits into from Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/rgw/rgw_coroutine.cc
Expand Up @@ -43,7 +43,6 @@ void RGWCompletionManager::register_completion_notifier(RGWAioCompletionNotifier
Mutex::Locker l(lock);
if (cn) {
cns.insert(cn);
cn->get();
}
}

Expand All @@ -52,15 +51,13 @@ void RGWCompletionManager::unregister_completion_notifier(RGWAioCompletionNotifi
Mutex::Locker l(lock);
if (cn) {
cns.erase(cn);
cn->put();
}
}

void RGWCompletionManager::_complete(RGWAioCompletionNotifier *cn, void *user_info)
{
if (cn) {
cns.erase(cn);
cn->put();
}
complete_reqs.push_back(user_info);
cond.Signal();
Expand Down
4 changes: 3 additions & 1 deletion src/rgw/rgw_coroutine.h
Expand Up @@ -7,6 +7,7 @@
#endif

#include <boost/asio.hpp>
#include <boost/intrusive_ptr.hpp>

#ifdef NEED_ASSERT_H
#pragma pop_macro("_ASSERT_H")
Expand All @@ -30,7 +31,8 @@ class RGWAioCompletionNotifier;
class RGWCompletionManager : public RefCountedObject {
CephContext *cct;
list<void *> complete_reqs;
set<RGWAioCompletionNotifier *> cns;
using NotifierRef = boost::intrusive_ptr<RGWAioCompletionNotifier>;
set<NotifierRef> cns;

Mutex lock;
Cond cond;
Expand Down
20 changes: 12 additions & 8 deletions src/rgw/rgw_cr_rados.h
Expand Up @@ -12,28 +12,28 @@ 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() {
get();
retcode = _send_request();
{
Mutex::Locker l(lock);
if (!done) {
notifier->cb();
if (notifier) {
notifier->cb(); // drops its own ref
notifier = nullptr;
}
}
put();
Expand All @@ -44,7 +44,11 @@ class RGWAsyncRadosRequest : public RefCountedObject {
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();
}
Expand Down