summaryrefslogtreecommitdiffstats
path: root/src/RemoteControl.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-10 11:19:51 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-10-10 11:24:01 +0200
commit4576c71f10dc009ce0dd9aedbc2f81a3e1a8be0e (patch)
tree4da48f2891e4daa6c539a221896f4378e3bead57 /src/RemoteControl.h
parentf16f9c0634693ce0a53bb269aa2d36402e51f92f (diff)
downloaddabmux-4576c71f10dc009ce0dd9aedbc2f81a3e1a8be0e.tar.gz
dabmux-4576c71f10dc009ce0dd9aedbc2f81a3e1a8be0e.tar.bz2
dabmux-4576c71f10dc009ce0dd9aedbc2f81a3e1a8be0e.zip
Fix telnet RC shutdown
Diffstat (limited to 'src/RemoteControl.h')
-rw-r--r--src/RemoteControl.h41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/RemoteControl.h b/src/RemoteControl.h
index da6f9ea..1c830aa 100644
--- a/src/RemoteControl.h
+++ b/src/RemoteControl.h
@@ -198,25 +198,25 @@ extern RemoteControllers rcs;
class RemoteControllerTelnet : public BaseRemoteController {
public:
RemoteControllerTelnet()
- : m_active(false), m_fault(false),
+ : m_active(false),
+ m_io_service(),
+ m_fault(false),
m_port(0) { }
RemoteControllerTelnet(int port)
- : m_active(port > 0), m_fault(false),
- m_child_thread(&RemoteControllerTelnet::process, this, 0),
- m_port(port) { }
+ : m_active(port > 0),
+ m_io_service(),
+ m_fault(false),
+ m_port(port)
+ {
+ restart();
+ }
+
RemoteControllerTelnet& operator=(const RemoteControllerTelnet& other) = delete;
RemoteControllerTelnet(const RemoteControllerTelnet& other) = delete;
- ~RemoteControllerTelnet() {
- m_active = false;
- m_fault = false;
- if (m_port) {
- m_child_thread.interrupt();
- m_child_thread.join();
- }
- }
+ ~RemoteControllerTelnet();
virtual bool fault_detected() { return m_fault; }
@@ -232,6 +232,10 @@ class RemoteControllerTelnet : public BaseRemoteController {
void reply(boost::asio::ip::tcp::socket& socket, std::string message);
+ void handle_accept(
+ const boost::system::error_code& boost_error,
+ boost::shared_ptr< boost::asio::ip::tcp::socket > socket,
+ boost::asio::ip::tcp::acceptor& acceptor);
std::vector<std::string> tokenise_(std::string message) {
std::vector<std::string> all_tokens;
@@ -245,6 +249,8 @@ class RemoteControllerTelnet : public BaseRemoteController {
std::atomic<bool> m_active;
+ boost::asio::io_service m_io_service;
+
/* This is set to true if a fault occurred */
std::atomic<bool> m_fault;
boost::thread m_restarter_thread;
@@ -274,16 +280,7 @@ class RemoteControllerZmq : public BaseRemoteController {
RemoteControllerZmq& operator=(const RemoteControllerZmq& other) = delete;
RemoteControllerZmq(const RemoteControllerZmq& other) = delete;
- ~RemoteControllerZmq() {
- m_active = false;
- m_fault = false;
-
- m_zmqContext.close();
- if (!m_endpoint.empty()) {
- m_child_thread.interrupt();
- m_child_thread.join();
- }
- }
+ ~RemoteControllerZmq();
virtual bool fault_detected() { return m_fault; }