From 08ae01231754d3010c1ede762579cf75c1c7460d Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 15 May 2015 10:45:04 -0400 Subject: [PATCH] librados_test_stub: watcher id should be the instance id (gid) Signed-off-by: Jason Dillaman (cherry picked from commit 3e1e561cc29043eb64dff8afb3a2c1ed77788e93) --- src/test/librados_test_stub/TestIoCtxImpl.cc | 3 ++- src/test/librados_test_stub/TestWatchNotify.cc | 8 +++++--- src/test/librados_test_stub/TestWatchNotify.h | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/test/librados_test_stub/TestIoCtxImpl.cc b/src/test/librados_test_stub/TestIoCtxImpl.cc index 41cbef58d2ba0..e376e63cba51a 100644 --- a/src/test/librados_test_stub/TestIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestIoCtxImpl.cc @@ -244,7 +244,8 @@ int TestIoCtxImpl::unwatch(uint64_t handle) { int TestIoCtxImpl::watch(const std::string& o, uint64_t *handle, librados::WatchCtx *ctx, librados::WatchCtx2 *ctx2) { - return m_client->get_watch_notify().watch(o, handle, ctx, ctx2); + return m_client->get_watch_notify().watch(o, get_instance_id(), handle, ctx, + ctx2); } int TestIoCtxImpl::execute_aio_operations(const std::string& oid, diff --git a/src/test/librados_test_stub/TestWatchNotify.cc b/src/test/librados_test_stub/TestWatchNotify.cc index 094bcb5b40589..14a43bc58cb1c 100644 --- a/src/test/librados_test_stub/TestWatchNotify.cc +++ b/src/test/librados_test_stub/TestWatchNotify.cc @@ -50,7 +50,7 @@ int TestWatchNotify::list_watchers(const std::string& o, it != watcher->watch_handles.end(); ++it) { obj_watch_t obj; strcpy(obj.addr, ":/0"); - obj.watcher_id = static_cast(it->second.handle); + obj.watcher_id = static_cast(it->second.instance_id); obj.cookie = it->second.handle; obj.timeout_seconds = 30; out_watchers->push_back(obj); @@ -113,12 +113,14 @@ void TestWatchNotify::notify_ack(const std::string& o, uint64_t notify_id, notify_handle->cond.Signal(); } -int TestWatchNotify::watch(const std::string& o, uint64_t *handle, - librados::WatchCtx *ctx, librados::WatchCtx2 *ctx2) { +int TestWatchNotify::watch(const std::string& o, uint64_t instance_id, + uint64_t *handle, librados::WatchCtx *ctx, + librados::WatchCtx2 *ctx2) { SharedWatcher watcher = get_watcher(o); RWLock::WLocker l(watcher->lock); WatchHandle watch_handle; + watch_handle.instance_id = instance_id; watch_handle.handle = ++m_handle; watch_handle.watch_ctx = ctx; watch_handle.watch_ctx2 = ctx2; diff --git a/src/test/librados_test_stub/TestWatchNotify.h b/src/test/librados_test_stub/TestWatchNotify.h index 4912ef27444a8..1761302bbf37b 100644 --- a/src/test/librados_test_stub/TestWatchNotify.h +++ b/src/test/librados_test_stub/TestWatchNotify.h @@ -35,6 +35,7 @@ public: typedef std::map NotifyHandles; struct WatchHandle { + uint64_t instance_id; uint64_t handle; librados::WatchCtx* watch_ctx; librados::WatchCtx2* watch_ctx2; @@ -60,7 +61,7 @@ public: uint64_t timeout_ms, bufferlist *pbl); void notify_ack(const std::string& o, uint64_t notify_id, uint64_t handle, uint64_t gid, bufferlist& bl); - int watch(const std::string& o, uint64_t *handle, + int watch(const std::string& o, uint64_t instance_id, uint64_t *handle, librados::WatchCtx *ctx, librados::WatchCtx2 *ctx2); int unwatch(uint64_t handle); -- 2.39.5