Skip to content

Commit

Permalink
librados_test_stub: fix helgrind warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit b65ae4b)
  • Loading branch information
Jason Dillaman committed Jul 28, 2015
1 parent b73e87e commit a5203d3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/test/librados_test_stub/TestClassHandler.cc
Expand Up @@ -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 {

Expand All @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/test/librados_test_stub/TestIoCtxImpl.cc
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
}
}

Expand Down
27 changes: 17 additions & 10 deletions src/test/librados_test_stub/TestWatchNotify.cc
Expand Up @@ -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;
Expand Down

0 comments on commit a5203d3

Please sign in to comment.