Fix some tsan warnings
This commit is contained in:
parent
fb24a249cb
commit
7287f1ca4d
@ -10,6 +10,7 @@
|
|||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <cpp-utils/macros.h>
|
#include <cpp-utils/macros.h>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
namespace fspp {
|
namespace fspp {
|
||||||
class Device;
|
class Device;
|
||||||
@ -69,7 +70,7 @@ private:
|
|||||||
Filesystem *_fs;
|
Filesystem *_fs;
|
||||||
boost::filesystem::path _mountdir;
|
boost::filesystem::path _mountdir;
|
||||||
std::vector<char*> _argv;
|
std::vector<char*> _argv;
|
||||||
bool _running;
|
std::atomic<bool> _running;
|
||||||
std::string _fstype;
|
std::string _fstype;
|
||||||
boost::optional<std::string> _fsname;
|
boost::optional<std::string> _fsname;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ using std::future;
|
|||||||
|
|
||||||
class ObjectWithLongDestructor {
|
class ObjectWithLongDestructor {
|
||||||
public:
|
public:
|
||||||
ObjectWithLongDestructor(ConditionBarrier *onDestructorStarted, bool *destructorFinished)
|
ObjectWithLongDestructor(ConditionBarrier *onDestructorStarted, std::atomic<bool> *destructorFinished)
|
||||||
: _onDestructorStarted(onDestructorStarted), _destructorFinished(destructorFinished) {}
|
: _onDestructorStarted(onDestructorStarted), _destructorFinished(destructorFinished) {}
|
||||||
~ObjectWithLongDestructor() {
|
~ObjectWithLongDestructor() {
|
||||||
_onDestructorStarted->release();
|
_onDestructorStarted->release();
|
||||||
@ -29,7 +29,7 @@ public:
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
ConditionBarrier *_onDestructorStarted;
|
ConditionBarrier *_onDestructorStarted;
|
||||||
bool *_destructorFinished;
|
std::atomic<bool> *_destructorFinished;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ObjectWithLongDestructor);
|
DISALLOW_COPY_AND_ASSIGN(ObjectWithLongDestructor);
|
||||||
};
|
};
|
||||||
@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
Cache<int, unique_ptr<ObjectWithLongDestructor>, MAX_ENTRIES> cache;
|
Cache<int, unique_ptr<ObjectWithLongDestructor>, MAX_ENTRIES> cache;
|
||||||
ConditionBarrier destructorStarted;
|
ConditionBarrier destructorStarted;
|
||||||
bool destructorFinished;
|
std::atomic<bool> destructorFinished;
|
||||||
|
|
||||||
int pushObjectWithLongDestructor() {
|
int pushObjectWithLongDestructor() {
|
||||||
cache.push(2, make_unique<ObjectWithLongDestructor>(&destructorStarted, &destructorFinished));
|
cache.push(2, make_unique<ObjectWithLongDestructor>(&destructorStarted, &destructorFinished));
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#include "MinimalKeyType.h"
|
#include "MinimalKeyType.h"
|
||||||
|
|
||||||
int MinimalKeyType::instances = 0;
|
std::atomic<int> MinimalKeyType::instances(0);
|
||||||
|
@ -3,11 +3,12 @@
|
|||||||
#define MESSMER_BLOCKSTORE_TEST_IMPLEMENTATIONS_CACHING_CACHE_TESTUTILS_MINIMALKEYTYPE_H_
|
#define MESSMER_BLOCKSTORE_TEST_IMPLEMENTATIONS_CACHING_CACHE_TESTUTILS_MINIMALKEYTYPE_H_
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
// This is a not-default-constructible Key type
|
// This is a not-default-constructible Key type
|
||||||
class MinimalKeyType {
|
class MinimalKeyType {
|
||||||
public:
|
public:
|
||||||
static int instances;
|
static std::atomic<int> instances;
|
||||||
|
|
||||||
static MinimalKeyType create(int value) {
|
static MinimalKeyType create(int value) {
|
||||||
return MinimalKeyType(value);
|
return MinimalKeyType(value);
|
||||||
|
@ -31,8 +31,10 @@ void FuseThread::start(const bf::path &mountDir, const vector<string> &fuseOptio
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FuseThread::stop() {
|
void FuseThread::stop() {
|
||||||
pthread_kill(_child.native_handle(), SIGINT);
|
if (0 != pthread_kill(_child.native_handle(), SIGINT)) {
|
||||||
bool thread_stopped = _child.try_join_for(seconds(5));
|
throw std::runtime_error("Error sending stop signal");
|
||||||
|
}
|
||||||
|
bool thread_stopped = _child.try_join_for(seconds(10));
|
||||||
ASSERT(thread_stopped, "FuseThread could not be stopped");
|
ASSERT(thread_stopped, "FuseThread could not be stopped");
|
||||||
//Wait until it is properly shutdown (busy waiting is simple and doesn't hurt much here)
|
//Wait until it is properly shutdown (busy waiting is simple and doesn't hurt much here)
|
||||||
while (_fuse->running()) {}
|
while (_fuse->running()) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user