If joining FuseThread fails, don't hang but fail an assertion
This commit is contained in:
parent
19f4d8bae5
commit
199552f42d
@ -3,7 +3,7 @@ INCLUDE(messmer/cmake/tools)
|
||||
# Actually create targets: EXEcutables and libraries.
|
||||
ADD_BII_TARGETS()
|
||||
|
||||
ADD_BOOST(filesystem system)
|
||||
ADD_BOOST(filesystem system thread chrono)
|
||||
|
||||
ACTIVATE_CPP14()
|
||||
REQUIRE_GCC_VERSION(4.8)
|
||||
|
@ -3,10 +3,11 @@
|
||||
#include <sys/wait.h>
|
||||
#include "FuseThread.h"
|
||||
#include <csignal>
|
||||
|
||||
#include <messmer/cpp-utils/assert/assert.h>
|
||||
#include "../../fuse/Fuse.h"
|
||||
|
||||
using std::thread;
|
||||
using boost::thread;
|
||||
using boost::chrono::seconds;
|
||||
using std::string;
|
||||
|
||||
using fspp::fuse::Fuse;
|
||||
@ -25,7 +26,8 @@ void FuseThread::start(int argc, char *argv[]) {
|
||||
|
||||
void FuseThread::stop() {
|
||||
pthread_kill(_child.native_handle(), SIGINT);
|
||||
_child.join();
|
||||
bool thread_stopped = _child.try_join_for(seconds(5));
|
||||
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()) {}
|
||||
}
|
||||
|
@ -2,7 +2,8 @@
|
||||
#ifndef MESSMER_FSPP_TEST_TESTUTILS_FUSETHREAD_H_
|
||||
#define MESSMER_FSPP_TEST_TESTUTILS_FUSETHREAD_H_
|
||||
|
||||
#include <thread>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
#include <messmer/cpp-utils/macros.h>
|
||||
|
||||
namespace fspp {
|
||||
@ -19,7 +20,7 @@ public:
|
||||
|
||||
private:
|
||||
fspp::fuse::Fuse *_fuse;
|
||||
std::thread _child;
|
||||
boost::thread _child;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(FuseThread);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user