Fix abort on module destruction if module has yet to be stopped, always stop modules before shutdown
Previously in daqinterface
: if a down
is commanded before modules are stopped with stop
, bool DAQProcess::m_run
would be set while the derived module destructs, causing resources likely used by std::thread DAQProcess::m_runner_thread
to be freed before the thread has joined. This is undefined behavior and caused an abort.
Now, down
also implies a stop
, correctly clearing m_run
before the interface exits. Furthermore, a module's destructor will not be called unless m_runner_thread
has joined, after which thread resources can safely be freed.