diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-02-14 21:37:04 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-02-14 21:37:47 +0100 |
commit | 18ac7c4644add4db18bcb7cd7cb3560cffe846b3 (patch) | |
tree | 4cb0d3d26d338d5b857023024c401cbfb6c5a09b /src/RemoteControl.cpp | |
parent | cba2e4929392272ce09219d1a691c059a580ab41 (diff) | |
download | dabmux-18ac7c4644add4db18bcb7cd7cb3560cffe846b3.tar.gz dabmux-18ac7c4644add4db18bcb7cd7cb3560cffe846b3.tar.bz2 dabmux-18ac7c4644add4db18bcb7cd7cb3560cffe846b3.zip |
restart RC if it did a fault
Diffstat (limited to 'src/RemoteControl.cpp')
-rw-r--r-- | src/RemoteControl.cpp | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/RemoteControl.cpp b/src/RemoteControl.cpp index fb1aa7e..3ce3310 100644 --- a/src/RemoteControl.cpp +++ b/src/RemoteControl.cpp @@ -26,16 +26,38 @@ #include <string> #include <string> #include <boost/asio.hpp> +#include <boost/thread.hpp> #include "Log.h" #include "RemoteControl.h" using boost::asio::ip::tcp; -void -RemoteControllerTelnet::process(long) + +void RemoteControllerTelnet::restart() +{ + m_restarter_thread = boost::thread(&RemoteControllerTelnet::restart_thread, + this, 0); +} + +// This runs in a separate thread, because +// it would take too long to be done in the main loop +// thread. +void RemoteControllerTelnet::restart_thread(long) +{ + m_running = false; + + if (m_port) { + m_child_thread.interrupt(); + m_child_thread.join(); + } + + m_child_thread = boost::thread(&RemoteControllerTelnet::process, this, 0); +} + +void RemoteControllerTelnet::process(long) { - m_welcome = "CRC-DABMUX Remote Control CLI\nWrite 'help' for help.\n**********\n"; + m_welcome = "ODR-DabMux Remote Control CLI\nWrite 'help' for help.\n**********\n"; m_prompt = "> "; std::string in_message; @@ -97,11 +119,11 @@ RemoteControllerTelnet::process(long) catch (std::exception& e) { etiLog.level(error) << "Remote control caught exception: " << e.what(); + m_fault = true; } } -void -RemoteControllerTelnet::dispatch_command(tcp::socket& socket, string command) +void RemoteControllerTelnet::dispatch_command(tcp::socket& socket, string command) { vector<string> cmd = tokenise_(command); @@ -214,8 +236,7 @@ RemoteControllerTelnet::dispatch_command(tcp::socket& socket, string command) } } -void -RemoteControllerTelnet::reply(tcp::socket& socket, string message) +void RemoteControllerTelnet::reply(tcp::socket& socket, string message) { boost::system::error_code ignored_error; stringstream ss; |