diff --git a/src/fspp/fuse/Fuse.h b/src/fspp/fuse/Fuse.h index 0b52d96c..84d904df 100644 --- a/src/fspp/fuse/Fuse.h +++ b/src/fspp/fuse/Fuse.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace fspp { class Device; @@ -69,7 +70,7 @@ private: Filesystem *_fs; boost::filesystem::path _mountdir; std::vector _argv; - bool _running; + std::atomic _running; std::string _fstype; boost::optional _fsname; diff --git a/test/blockstore/implementations/caching/cache/CacheTest_RaceCondition.cpp b/test/blockstore/implementations/caching/cache/CacheTest_RaceCondition.cpp index 51531e58..7bc76c3b 100644 --- a/test/blockstore/implementations/caching/cache/CacheTest_RaceCondition.cpp +++ b/test/blockstore/implementations/caching/cache/CacheTest_RaceCondition.cpp @@ -20,7 +20,7 @@ using std::future; class ObjectWithLongDestructor { public: - ObjectWithLongDestructor(ConditionBarrier *onDestructorStarted, bool *destructorFinished) + ObjectWithLongDestructor(ConditionBarrier *onDestructorStarted, std::atomic *destructorFinished) : _onDestructorStarted(onDestructorStarted), _destructorFinished(destructorFinished) {} ~ObjectWithLongDestructor() { _onDestructorStarted->release(); @@ -29,7 +29,7 @@ public: } private: ConditionBarrier *_onDestructorStarted; - bool *_destructorFinished; + std::atomic *_destructorFinished; DISALLOW_COPY_AND_ASSIGN(ObjectWithLongDestructor); }; @@ -42,7 +42,7 @@ public: Cache, MAX_ENTRIES> cache; ConditionBarrier destructorStarted; - bool destructorFinished; + std::atomic destructorFinished; int pushObjectWithLongDestructor() { cache.push(2, make_unique(&destructorStarted, &destructorFinished)); diff --git a/test/blockstore/implementations/caching/cache/testutils/MinimalKeyType.cpp b/test/blockstore/implementations/caching/cache/testutils/MinimalKeyType.cpp index f6b327ff..0b16bdac 100644 --- a/test/blockstore/implementations/caching/cache/testutils/MinimalKeyType.cpp +++ b/test/blockstore/implementations/caching/cache/testutils/MinimalKeyType.cpp @@ -1,3 +1,3 @@ #include "MinimalKeyType.h" -int MinimalKeyType::instances = 0; +std::atomic MinimalKeyType::instances(0); diff --git a/test/blockstore/implementations/caching/cache/testutils/MinimalKeyType.h b/test/blockstore/implementations/caching/cache/testutils/MinimalKeyType.h index 14dfb5be..9c66ba90 100644 --- a/test/blockstore/implementations/caching/cache/testutils/MinimalKeyType.h +++ b/test/blockstore/implementations/caching/cache/testutils/MinimalKeyType.h @@ -3,11 +3,12 @@ #define MESSMER_BLOCKSTORE_TEST_IMPLEMENTATIONS_CACHING_CACHE_TESTUTILS_MINIMALKEYTYPE_H_ #include +#include // This is a not-default-constructible Key type class MinimalKeyType { public: - static int instances; + static std::atomic instances; static MinimalKeyType create(int value) { return MinimalKeyType(value); diff --git a/test/fspp/testutils/FuseThread.cpp b/test/fspp/testutils/FuseThread.cpp index 1ddfe9ef..09804c3a 100644 --- a/test/fspp/testutils/FuseThread.cpp +++ b/test/fspp/testutils/FuseThread.cpp @@ -31,8 +31,10 @@ void FuseThread::start(const bf::path &mountDir, const vector &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()) {}