diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-03-22 21:25:46 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-06-19 10:43:57 +0200 |
commit | 93cbefeeffcba044ab95ee46307ab50ec717bf2b (patch) | |
tree | 4a92f0bf1715ac8eeef149a6e2d33d318513c2d4 /src/ManagementServer.h | |
parent | 76e7f0f79c908bf7d0a447ea643dbcdde8f064d2 (diff) | |
download | dabmux-93cbefeeffcba044ab95ee46307ab50ec717bf2b.tar.gz dabmux-93cbefeeffcba044ab95ee46307ab50ec717bf2b.tar.bz2 dabmux-93cbefeeffcba044ab95ee46307ab50ec717bf2b.zip |
Use boost::asio in Management Server
Diffstat (limited to 'src/ManagementServer.h')
-rw-r--r-- | src/ManagementServer.h | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/ManagementServer.h b/src/ManagementServer.h index c71f6d2..cea692f 100644 --- a/src/ManagementServer.h +++ b/src/ManagementServer.h @@ -52,15 +52,12 @@ # include "config.h" #endif -#include <sys/socket.h> -#include <netinet/in.h> -#include <unistd.h> -#include <netdb.h> -#include <arpa/inet.h> -#include <pthread.h> #include <string> #include <map> +#include <atomic> #include <boost/thread.hpp> +#include <boost/asio.hpp> +#include <boost/bind.hpp> #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/json_parser.hpp> #include <ctime> @@ -317,6 +314,7 @@ class ManagementServer { public: ManagementServer() : + m_io_service(), m_running(false), m_fault(false), m_pending(false) { } @@ -326,10 +324,8 @@ class ManagementServer m_running = false; m_fault = false; m_pending = false; - if (m_sock) { - close(m_sock); - m_thread.interrupt(); - } + + m_io_service.stop(); m_thread.join(); } @@ -337,7 +333,6 @@ class ManagementServer { m_listenport = listenport; if (m_listenport > 0) { - m_sock = 0; m_thread = boost::thread(&ManagementServer::serverThread, this); } } @@ -364,6 +359,8 @@ class ManagementServer void restart(void); private: + boost::asio::io_service m_io_service; + void restart_thread(long); /******* TCP Socket Server ******/ @@ -374,16 +371,19 @@ class ManagementServer bool isInputRegistered(std::string& id); + 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); + int m_listenport; // serverThread runs in a separate thread - bool m_running; - bool m_fault; + std::atomic<bool> m_running; + std::atomic<bool> m_fault; boost::thread m_thread; boost::thread m_restarter_thread; - int m_sock; - /******* Statistics Data ********/ std::map<std::string, InputStat*> m_inputStats; |