Skip to content

Commit

Permalink
Merge pull request #13033 from dillaman/wip-18618
Browse files Browse the repository at this point in the history
journal: don't hold future lock during assignment

Reviewed-by: Mykola Golub <mgolub@mirantis.com>
  • Loading branch information
Mykola Golub committed Jan 22, 2017
2 parents 2441305 + 0f21cee commit fce69f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/journal/FutureImpl.cc
Expand Up @@ -39,13 +39,12 @@ void FutureImpl::flush(Context *on_safe) {
m_contexts.push_back(on_safe);
}

prev_future = prepare_flush(&flush_handlers);
prev_future = prepare_flush(&flush_handlers, m_lock);
}
}

// instruct prior futures to flush as well
while (prev_future) {
Mutex::Locker locker(prev_future->m_lock);
prev_future = prev_future->prepare_flush(&flush_handlers);
}

Expand All @@ -62,6 +61,12 @@ void FutureImpl::flush(Context *on_safe) {
}

FutureImplPtr FutureImpl::prepare_flush(FlushHandlers *flush_handlers) {
Mutex::Locker locker(m_lock);
return prepare_flush(flush_handlers, m_lock);
}

FutureImplPtr FutureImpl::prepare_flush(FlushHandlers *flush_handlers,
Mutex &lock) {
assert(m_lock.is_locked());

if (m_flush_state == FLUSH_STATE_NONE) {
Expand Down
1 change: 1 addition & 0 deletions src/journal/FutureImpl.h
Expand Up @@ -113,6 +113,7 @@ class FutureImpl : public RefCountedObject, boost::noncopyable {
Contexts m_contexts;

FutureImplPtr prepare_flush(FlushHandlers *flush_handlers);
FutureImplPtr prepare_flush(FlushHandlers *flush_handlers, Mutex &lock);

void consistent(int r);
void finish_unlock();
Expand Down

0 comments on commit fce69f6

Please sign in to comment.