]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados_test_stub: fix helgrind warnings
authorJason Dillaman <dillaman@redhat.com>
Thu, 30 Apr 2015 17:37:56 +0000 (13:37 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 28 Jul 2015 20:34:22 +0000 (16:34 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit b65ae4bc26f2dcaaa9518d5cce0e8b83ea310de8)

src/test/librados_test_stub/TestClassHandler.cc
src/test/librados_test_stub/TestIoCtxImpl.cc
src/test/librados_test_stub/TestWatchNotify.cc

index c7a2e96fd8874685b6eeb36e17df588eac0bfa34..27325529ecf3002fc72dc0d531b2d599f06210a1 100644 (file)
@@ -5,6 +5,9 @@
 #include <boost/algorithm/string/predicate.hpp>
 #include <dlfcn.h>
 #include <errno.h>
+#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);
index f810906a19e645aed340ce888dccaae4a6aa05bd..41cbef58d2ba041731a331b0e49067a74ffca31d 100644 (file)
@@ -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 <boost/bind.hpp>
 #include <errno.h>
@@ -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);
   }
 }
 
index d51b893cf8d94d6efced7072ba5e8880e4963f05..094bcb5b4058912118113ad1c10e2282fefcf716 100644 (file)
@@ -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;