diff options
Diffstat (limited to 'src/Core')
-rw-r--r-- | src/Core/ConnectionManager.cpp | 9 | ||||
-rw-r--r-- | src/Core/ConnectionManager.h | 14 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp index 7df9e8b..833e2e6 100644 --- a/src/Core/ConnectionManager.cpp +++ b/src/Core/ConnectionManager.cpp @@ -42,7 +42,7 @@ namespace Mad { namespace Core { -ConnectionManager ConnectionManager::connectionManager; +Common::SingletonPtr<ConnectionManager> ConnectionManager::connectionManager; void ConnectionManager::updateState(const std::string &name, Common::HostInfo::State state) { @@ -129,9 +129,8 @@ void ConnectionManager::configFinished() { } } -void ConnectionManager::doInit() { +ConnectionManager::ConnectionManager() { Common::RequestManager::get()->setCore(true); - Common::RequestManager::get()->init(); Common::RequestManager::get()->registerPacketType<Common::RequestHandlers::FSInfoRequestHandler>(Net::Packet::FS_INFO); Common::RequestManager::get()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>(Net::Packet::STATUS); @@ -147,7 +146,7 @@ void ConnectionManager::doInit() { Net::Connection::init(); } -void ConnectionManager::doDeinit() { +ConnectionManager::~ConnectionManager() { for(std::list<Net::ServerConnection*>::iterator con = daemonConnections.begin(); con != daemonConnections.end(); ++con) delete *con; @@ -183,7 +182,7 @@ void ConnectionManager::handleConnections(std::list<Net::ServerConnection*>& con void ConnectionManager::run() { // TODO Logging - Net::FdManager::getFdManager()->run(); + Net::FdManager::get()->run(); handleConnections(daemonConnections); handleConnections(clientConnections); diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h index c17bae5..86c342c 100644 --- a/src/Core/ConnectionManager.h +++ b/src/Core/ConnectionManager.h @@ -27,8 +27,8 @@ #include <Common/Configurable.h> #include <Common/Exception.h> #include <Common/HostInfo.h> -#include <Common/Initializable.h> #include <Common/RequestManager.h> +#include <Common/SingletonPtr.h> #include <Net/IPAddress.h> @@ -45,7 +45,7 @@ namespace Core { class ConnectionManager : public Common::Configurable { private: - static ConnectionManager connectionManager; + static Common::SingletonPtr<ConnectionManager> connectionManager; std::string x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile; @@ -62,22 +62,20 @@ class ConnectionManager : public Common::Configurable { ConnectionManager(const ConnectionManager &o); ConnectionManager& operator=(const ConnectionManager &o); - ConnectionManager() {} - void handleConnections(std::list<Net::ServerConnection*> &connections); void updateState(const std::string &name, Common::HostInfo::State state); protected: - virtual void doInit(); - virtual void doDeinit(); - virtual bool handleConfigEntry(const Common::ConfigEntry &entry, bool handled); virtual void configFinished(); public: + ConnectionManager(); + virtual ~ConnectionManager(); + static ConnectionManager* get() { - return &connectionManager; + return connectionManager.get(); } void run(); |