]> 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>
Thu, 4 Jun 2015 20:49:51 +0000 (16:49 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librados_test_stub/TestClassHandler.cc
src/test/librados_test_stub/TestIoCtxImpl.cc
src/test/librados_test_stub/TestWatchNotify.cc

index e55770f4e43f50dd80dfb4da4e519549c03495eb..1ac29cd35694ee70d05e64ec3869f75bb1c9404b 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 36be941bdef23dc3a89ecb32d4c4258370754e02..39cd8b4a85d1a1b4a7208e1e9ee11292e2ef3b06 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;