Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #103 from NordicSemiconductor/fix/state-check-and-…
Browse files Browse the repository at this point in the history
…cleanup-transports

Fix transport cleanup and check if state machine thread exists
  • Loading branch information
kenr committed May 22, 2018
2 parents 8cdbeb1 + 85cee39 commit 253bd54
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/common/transport/h5_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,11 @@ void H5Transport::startStateMachine()
{
stateMachineThread = new std::thread(std::bind(&H5Transport::stateMachineWorker, this));
}
else
{
// Terminate if the state machine already exists, this should not happen.
std::terminate();
}
}

void H5Transport::stopStateMachine()
Expand Down
4 changes: 1 addition & 3 deletions src/common/transport/serialization_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@ uint32_t SerializationTransport::open(status_cb_t status_callback, evt_cb_t even

uint32_t SerializationTransport::close()
{
eventMutex.lock();
runEventThread = false;
eventWaitCondition.notify_one();
eventMutex.unlock();
eventWaitCondition.notify_all();

if (eventThread != nullptr)
{
Expand Down
5 changes: 1 addition & 4 deletions src/common/transport/uart_boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ UartBoost::UartBoost(const UartCommunicationParameters &communicationParameters)

UartBoost::~UartBoost()
{
UartBoost::close();
workNotifier.~work();
ioWorkThread.join();
ioService.stop();
}

uint32_t UartBoost::open(status_cb_t status_callback, data_cb_t data_callback, log_cb_t log_callback)
Expand Down Expand Up @@ -174,6 +170,7 @@ uint32_t UartBoost::close()
{
try
{
serialPort.cancel();
serialPort.close();
ioService.stop();
ioWorkThread.join();
Expand Down

0 comments on commit 253bd54

Please sign in to comment.