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