Skip to content
Snippets Groups Projects
Commit 0fb955c3 authored by Eric Cano's avatar Eric Cano
Browse files

In Rados notify based locking, prevented multiple promise setting.

This happens when the notification is received multiple times. This did not show
before full scale test.
parent a6c8156e
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@
#include "BackendRados.hpp"
#include "common/exception/Errnum.hpp"
#include "common/Timer.hpp"
#include "common/threading/MutexLocker.hpp"
#include <rados/librados.hpp>
#include <sys/syscall.h>
#include <errno.h>
......@@ -210,13 +211,17 @@ BackendRados::LockWatcher::LockWatcher(librados::IoCtx& context, const std::stri
}
void BackendRados::LockWatcher::handle_error(uint64_t cookie, int err) {
threading::MutexLocker ml(m_promiseMutex);
m_promise.set_value();
TIMESTAMPEDPRINT("");
TIMESTAMPEDPRINT("Handled notify");
m_promiseSet = true;
}
void BackendRados::LockWatcher::handle_notify(uint64_t notify_id, uint64_t cookie, uint64_t notifier_id, librados::bufferlist& bl) {
threading::MutexLocker ml(m_promiseMutex);
m_promise.set_value();
TIMESTAMPEDPRINT("");
TIMESTAMPEDPRINT("Handled notify");
m_promiseSet = true;
}
void BackendRados::LockWatcher::wait(const durationUs& timeout) {
......
......@@ -20,6 +20,7 @@
#include "Backend.hpp"
#include "rados/librados.hpp"
#include "common/threading/Mutex.hpp"
#include <future>
......@@ -105,6 +106,10 @@ private:
typedef std::chrono::microseconds durationUs;
void wait(const durationUs & timeout);
private:
// We could receive several notifications. The promise should be set only
// on the first occurrence.
threading::Mutex m_promiseMutex;
bool m_promiseSet = false;
std::promise<void> m_promise;
std::future<void> m_future;
librados::IoCtx & m_context;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment