From: Jason Dillaman Date: Thu, 30 Apr 2015 17:37:56 +0000 (-0400) Subject: librados_test_stub: fix helgrind warnings X-Git-Tag: v0.94.4~77^2~24 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a5203d32544d40cb51eb60fc906cc3ceaacbfe96;p=ceph.git librados_test_stub: fix helgrind warnings Signed-off-by: Jason Dillaman (cherry picked from commit b65ae4bc26f2dcaaa9518d5cce0e8b83ea310de8) --- diff --git a/src/test/librados_test_stub/TestClassHandler.cc b/src/test/librados_test_stub/TestClassHandler.cc index c7a2e96fd887..27325529ecf3 100644 --- a/src/test/librados_test_stub/TestClassHandler.cc +++ b/src/test/librados_test_stub/TestClassHandler.cc @@ -5,6 +5,9 @@ #include #include #include +#include "common/debug.h" + +#define dout_subsys ceph_subsys_rados namespace librados { @@ -22,7 +25,7 @@ void TestClassHandler::open_class(const std::string& name, const std::string& path) { void *handle = dlopen(path.c_str(), RTLD_NOW); if (handle == NULL) { - std::cerr << "Failed to load class: " << dlerror() << std::endl; + derr << "Failed to load class: " << dlerror() << dendl; return; } m_class_handles.push_back(handle); diff --git a/src/test/librados_test_stub/TestIoCtxImpl.cc b/src/test/librados_test_stub/TestIoCtxImpl.cc index f810906a19e6..41cbef58d2ba 100644 --- a/src/test/librados_test_stub/TestIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestIoCtxImpl.cc @@ -7,6 +7,7 @@ #include "test/librados_test_stub/TestWatchNotify.h" #include "librados/AioCompletionImpl.h" #include "include/assert.h" +#include "common/valgrind.h" #include "objclass/objclass.h" #include #include @@ -45,7 +46,11 @@ void TestObjectOperationImpl::get() { void TestObjectOperationImpl::put() { if (m_refcount.dec() == 0) { + ANNOTATE_HAPPENS_AFTER(&m_refcount); + ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(&m_refcount); delete this; + } else { + ANNOTATE_HAPPENS_BEFORE(&m_refcount); } } diff --git a/src/test/librados_test_stub/TestWatchNotify.cc b/src/test/librados_test_stub/TestWatchNotify.cc index d51b893cf8d9..094bcb5b4058 100644 --- a/src/test/librados_test_stub/TestWatchNotify.cc +++ b/src/test/librados_test_stub/TestWatchNotify.cc @@ -169,20 +169,27 @@ void TestWatchNotify::execute_notify(const std::string &oid, bufferlist &bl, uint64_t notify_id, Mutex *lock, Cond *cond, bool *done) { - SharedWatcher watcher = get_watcher(oid); - RWLock::RLocker l(watcher->lock); + WatchHandles watch_handles; + SharedNotifyHandle notify_handle; - utime_t timeout; - timeout.set_from_double(ceph_clock_now(m_cct) + 15); + { + SharedWatcher watcher = get_watcher(oid); + RWLock::RLocker l(watcher->lock); - NotifyHandles::iterator n_it = watcher->notify_handles.find(notify_id); - if (n_it == watcher->notify_handles.end()) { - return; + NotifyHandles::iterator n_it = watcher->notify_handles.find(notify_id); + if (n_it == watcher->notify_handles.end()) { + return; + } + + watch_handles = watcher->watch_handles; + notify_handle = n_it->second; } - SharedNotifyHandle notify_handle = n_it->second; - for (WatchHandles::iterator w_it = watcher->watch_handles.begin(); - w_it != watcher->watch_handles.end(); ++w_it) { + utime_t timeout; + timeout.set_from_double(ceph_clock_now(m_cct) + 15); + + for (WatchHandles::iterator w_it = watch_handles.begin(); + w_it != watch_handles.end(); ++w_it) { WatchHandle &watch_handle = w_it->second; bufferlist notify_bl;