From 7514a3951bdee4fe71f877e83fc6acf18bc847e5 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 11 Apr 2018 15:29:49 +0200 Subject: Fix thread handling in remotecontrol --- src/RemoteControl.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/RemoteControl.cpp') diff --git a/src/RemoteControl.cpp b/src/RemoteControl.cpp index 6e6a7e9..a3d9ec3 100644 --- a/src/RemoteControl.cpp +++ b/src/RemoteControl.cpp @@ -53,6 +53,10 @@ RemoteControllerTelnet::~RemoteControllerTelnet() void RemoteControllerTelnet::restart() { + if (m_restarter_thread.joinable()) { + m_restarter_thread.join(); + } + m_restarter_thread = std::thread( &RemoteControllerTelnet::restart_thread, this, 0); @@ -105,7 +109,9 @@ void RemoteControllerTelnet::restart_thread(long) m_active = false; m_io_service.stop(); - m_child_thread.join(); + if (m_child_thread.joinable()) { + m_child_thread.join(); + } m_child_thread = std::thread(&RemoteControllerTelnet::process, this, 0); } @@ -342,6 +348,10 @@ RemoteControllerZmq::~RemoteControllerZmq() { void RemoteControllerZmq::restart() { + if (m_restarter_thread.joinable()) { + m_restarter_thread.join(); + } + m_restarter_thread = std::thread(&RemoteControllerZmq::restart_thread, this); } -- cgit v1.2.3