diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-03-21 14:30:09 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-06-19 10:43:35 +0200 |
commit | 76e7f0f79c908bf7d0a447ea643dbcdde8f064d2 (patch) | |
tree | 214230901ec43d923e1696c54005a123278df086 /src/ManagementServer.cpp | |
parent | 0ac177534620caa13864f9bfcd804004e3e538fd (diff) | |
download | dabmux-76e7f0f79c908bf7d0a447ea643dbcdde8f064d2.tar.gz dabmux-76e7f0f79c908bf7d0a447ea643dbcdde8f064d2.tar.bz2 dabmux-76e7f0f79c908bf7d0a447ea643dbcdde8f064d2.zip |
Start big refactoring
Multiplexer in separate object
Replace pointers by shared_ptr
Switch to C++11
Diffstat (limited to 'src/ManagementServer.cpp')
-rw-r--r-- | src/ManagementServer.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/ManagementServer.cpp b/src/ManagementServer.cpp index 78f1c9d..0aa9ed8 100644 --- a/src/ManagementServer.cpp +++ b/src/ManagementServer.cpp @@ -39,6 +39,18 @@ #include "ManagementServer.h" #include "Log.h" +ManagementServer& get_mgmt_server() +{ + static ManagementServer mgmt_server; + + return mgmt_server; + + /* Warning, do not use the mgmt_server in the destructor + * of another global object: you don't know which one + * gets destroyed first + */ +} + void ManagementServer::registerInput(InputStat* is) { boost::mutex::scoped_lock lock(m_statsmutex); @@ -71,7 +83,7 @@ bool ManagementServer::isInputRegistered(std::string& id) if (m_inputStats.count(id) == 0) { etiLog.level(error) << - "Stats Server id '" << + "Management Server: id '" << id << "' does was not registered"; return false; } @@ -253,7 +265,7 @@ void ManagementServer::serverThread() n = write(accepted_sock, welcome_msg, welcome_msg_len); if (n < 0) { etiLog.level(warn) << - "MGMT: Error writing to Stats Server socket " << + "MGMT: Error writing to Server socket " << strerror(errno); close(accepted_sock); continue; @@ -264,7 +276,7 @@ void ManagementServer::serverThread() int n = read(accepted_sock, buffer, 255); if (n < 0) { etiLog.level(warn) << - "MGMT: Error reading from Stats Server socket " << + "MGMT: Error reading from Server socket " << strerror(errno); close(accepted_sock); continue; @@ -383,12 +395,12 @@ void ManagementServer::update_ptree(const boost::property_tree::ptree& pt) void InputStat::registerAtServer() { - mgmt_server->registerInput(this); + get_mgmt_server().registerInput(this); } InputStat::~InputStat() { - mgmt_server->unregisterInput(m_name); + get_mgmt_server().unregisterInput(m_name); } std::string InputStat::encodeValuesJSON() |