summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Client/InformationManager.cpp12
-rw-r--r--src/Client/InformationManager.h17
-rw-r--r--src/Common/Backends/SystemBackendPosix.cpp4
-rw-r--r--src/Common/Initializable.cpp12
-rw-r--r--src/Common/Initializable.h1
-rw-r--r--src/Common/LogManager.cpp2
-rw-r--r--src/Common/LogManager.h9
-rw-r--r--src/Common/Makefile.am2
-rw-r--r--src/Common/Makefile.in2
-rw-r--r--src/Common/RequestManager.cpp4
-rw-r--r--src/Common/RequestManager.h21
-rw-r--r--src/Common/SingletonPtr.h63
-rw-r--r--src/Core/ConnectionManager.cpp9
-rw-r--r--src/Core/ConnectionManager.h14
-rw-r--r--src/Net/ClientConnection.cpp2
-rw-r--r--src/Net/Connection.cpp4
-rw-r--r--src/Net/FdManager.h2
-rw-r--r--src/Net/Listener.cpp2
-rw-r--r--src/Net/ServerConnection.cpp2
-rw-r--r--src/mad.cpp5
-rw-r--r--src/madc.cpp18
21 files changed, 135 insertions, 72 deletions
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp
index 37835c1..a2f67cb 100644
--- a/src/Client/InformationManager.cpp
+++ b/src/Client/InformationManager.cpp
@@ -28,7 +28,7 @@
namespace Mad {
namespace Client {
-InformationManager InformationManager::informationManager;
+Common::SingletonPtr<InformationManager> InformationManager::informationManager;
void InformationManager::DaemonStateUpdateRequest::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
@@ -44,8 +44,8 @@ void InformationManager::DaemonStateUpdateRequest::handlePacket(Net::Connection
Net::Packets::HostStatePacket hostStatePacket(packet);
- std::map<std::string, Common::HostInfo>::iterator host = informationManager.daemons.find(hostStatePacket.getName());
- if(host != informationManager.daemons.end())
+ std::map<std::string, Common::HostInfo>::iterator host = informationManager.get()->daemons.find(hostStatePacket.getName());
+ if(host != informationManager.get()->daemons.end())
host->second.setState(hostStatePacket.getState());
else
Common::Logger::log(Common::Logger::WARNING, "Received a state update for an unknown host.");
@@ -56,13 +56,11 @@ void InformationManager::DaemonStateUpdateRequest::handlePacket(Net::Connection
}
-void InformationManager::doInit() {
- Common::RequestManager::get()->init();
-
+InformationManager::InformationManager() : updating(false) {
Common::RequestManager::get()->registerPacketType<DaemonStateUpdateRequest>(Net::Packet::DAEMON_STATE_UPDATE);
}
-void InformationManager::doUninit() {
+InformationManager::~InformationManager() {
Common::RequestManager::get()->unregisterPacketType(Net::Packet::DAEMON_STATE_UPDATE);
}
diff --git a/src/Client/InformationManager.h b/src/Client/InformationManager.h
index 4acde37..1464e2f 100644
--- a/src/Client/InformationManager.h
+++ b/src/Client/InformationManager.h
@@ -24,8 +24,8 @@
#include <memory>
#include <Common/HostInfo.h>
-#include <Common/Initializable.h>
#include <Common/Request.h>
+#include <Common/SingletonPtr.h>
namespace Mad {
@@ -40,7 +40,7 @@ class HostListPacket;
namespace Client {
-class InformationManager : public Common::Initializable {
+class InformationManager {
private:
class DaemonStateUpdateRequest : public Common::RequestHandler {
protected:
@@ -50,7 +50,7 @@ class InformationManager : public Common::Initializable {
DaemonStateUpdateRequest() {}
};
- static InformationManager informationManager;
+ static Common::SingletonPtr<InformationManager> informationManager;
std::map<std::string, Common::HostInfo> daemons;
@@ -60,19 +60,16 @@ class InformationManager : public Common::Initializable {
InformationManager(const InformationManager &o);
InformationManager& operator=(const InformationManager &o);
- InformationManager() : updating(false) {}
-
void daemonListRequestFinished(const Common::Request<Net::Packets::HostListPacket> &request);
- protected:
- virtual void doInit();
- virtual void doUninit();
-
public:
static InformationManager* get() {
- return &informationManager;
+ return informationManager.get();
}
+ InformationManager();
+ virtual ~InformationManager();
+
void updateDaemonList(Net::Connection *con);
bool isUpdating() const {
diff --git a/src/Common/Backends/SystemBackendPosix.cpp b/src/Common/Backends/SystemBackendPosix.cpp
index 62067c2..bff72db 100644
--- a/src/Common/Backends/SystemBackendPosix.cpp
+++ b/src/Common/Backends/SystemBackendPosix.cpp
@@ -131,7 +131,7 @@ void SystemBackendPosix::childHandler(int) {
while((n = read(handle, buffer, sizeof(buffer))) > 0)
output += std::string(buffer, n);
- Net::FdManager::getFdManager()->unregisterFd(handle);
+ Net::FdManager::get()->unregisterFd(handle);
close(handle);
it2->second(status, output);
@@ -266,7 +266,7 @@ bool SystemBackendPosix::execWithOutput(const sigc::slot<void, int, const std::s
processesWOHandles.insert(std::make_pair(pid, pipeHandles[0]));
processesWOOutput.insert(std::make_pair(pid, std::string()));
- Net::FdManager::getFdManager()->registerFd(pipeHandles[0], sigc::bind(sigc::ptr_fun(&SystemBackendPosix::outputHandler), pid), POLLIN);
+ Net::FdManager::get()->registerFd(pipeHandles[0], sigc::bind(sigc::ptr_fun(&SystemBackendPosix::outputHandler), pid), POLLIN);
}
dup2(saveStdout, STDOUT_FILENO); // restore old stdout
diff --git a/src/Common/Initializable.cpp b/src/Common/Initializable.cpp
index 9e7a49e..65893a1 100644
--- a/src/Common/Initializable.cpp
+++ b/src/Common/Initializable.cpp
@@ -28,12 +28,17 @@ namespace Mad {
namespace Common {
std::stack<Initializable*> Initializable::initializedObjects;
-
+bool Initializable::logInit = false;
void Initializable::init() {
if(initialized)
return;
+ if(!logInit) {
+ logInit = true;
+ LogManager::get();
+ }
+
if(initializing) {
Logger::log(Logger::CRITICAL, "Fatal initialization error: cyclic dependencies.");
std::terminate();
@@ -41,9 +46,6 @@ void Initializable::init() {
initializing = true;
- if(!(LogManager::get()->isInitialized() || LogManager::get()->isInitializing()))
- LogManager::get()->init();
-
doInit();
Configurable *c = dynamic_cast<Configurable*>(this);
@@ -68,6 +70,8 @@ void Initializable::deinit() {
initializedObjects.pop();
}
+
+ logInit = false;
}
}
diff --git a/src/Common/Initializable.h b/src/Common/Initializable.h
index 6f67678..27ab5bf 100644
--- a/src/Common/Initializable.h
+++ b/src/Common/Initializable.h
@@ -28,6 +28,7 @@ namespace Common {
class Initializable {
private:
static std::stack<Initializable*> initializedObjects;
+ static bool logInit;
bool initializing;
bool initialized;
diff --git a/src/Common/LogManager.cpp b/src/Common/LogManager.cpp
index d974d7c..09cdd10 100644
--- a/src/Common/LogManager.cpp
+++ b/src/Common/LogManager.cpp
@@ -26,7 +26,7 @@
namespace Mad {
namespace Common {
-LogManager LogManager::logManager;
+SingletonPtr<LogManager> LogManager::logManager;
bool LogManager::handleConfigEntry(const ConfigEntry &entry, bool handled) {
diff --git a/src/Common/LogManager.h b/src/Common/LogManager.h
index 22a8c75..7c0f1e0 100644
--- a/src/Common/LogManager.h
+++ b/src/Common/LogManager.h
@@ -23,6 +23,7 @@
#include "Configurable.h"
#include "Logger.h"
#include "RemoteLogger.h"
+#include "SingletonPtr.h"
#include "SharedPtr.h"
#include <memory>
@@ -52,7 +53,7 @@ class LogManager : public Configurable {
std::string source;
};
- static LogManager logManager;
+ static SingletonPtr<LogManager> logManager;
std::set<SharedPtr<Logger> > loggers;
std::set<SharedPtr<RemoteLogger> > remoteLoggers;
@@ -60,13 +61,13 @@ class LogManager : public Configurable {
std::auto_ptr<std::queue<Message> > messageQueue;
std::auto_ptr<std::queue<RemoteMessage> > remoteMessageQueue;
- LogManager() : messageQueue(new std::queue<Message>()), remoteMessageQueue(new std::queue<RemoteMessage>()) {}
-
protected:
virtual bool handleConfigEntry(const ConfigEntry &entry, bool handled);
virtual void configFinished();
public:
+ LogManager() : messageQueue(new std::queue<Message>()), remoteMessageQueue(new std::queue<RemoteMessage>()) {}
+
void log(MessageCategory category, MessageLevel level, time_t timestamp, const std::string &message);
void log(MessageCategory category, MessageLevel level, time_t timestamp, const std::string &message, const std::string &source);
@@ -87,7 +88,7 @@ class LogManager : public Configurable {
}
static LogManager *get() {
- return &logManager;
+ return logManager.get();
}
};
diff --git a/src/Common/Makefile.am b/src/Common/Makefile.am
index 20daebb..7375c64 100644
--- a/src/Common/Makefile.am
+++ b/src/Common/Makefile.am
@@ -7,4 +7,4 @@ libcommon_la_LIBADD = Backends/libbackends.la Requests/librequests.la RequestHa
noinst_HEADERS = ConfigEntry.h ConfigManager.h Configurable.h Exception.h HostInfo.h Initializable.h \
Logger.h LoggerBase.h LogManager.h RemoteLogger.h Request.h RequestBase.h \
- RequestHandler.h RequestManager.h SharedPtr.h SystemBackend.h Tokenizer.h
+ RequestHandler.h RequestManager.h SharedPtr.h SingletonPtr.h SystemBackend.h Tokenizer.h
diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in
index 3bd9f4a..b011031 100644
--- a/src/Common/Makefile.in
+++ b/src/Common/Makefile.in
@@ -207,7 +207,7 @@ libcommon_la_SOURCES = ConfigEntry.cpp ConfigManager.cpp Exception.cpp Initializ
libcommon_la_LIBADD = Backends/libbackends.la Requests/librequests.la RequestHandlers/librequesthandlers.la
noinst_HEADERS = ConfigEntry.h ConfigManager.h Configurable.h Exception.h HostInfo.h Initializable.h \
Logger.h LoggerBase.h LogManager.h RemoteLogger.h Request.h RequestBase.h \
- RequestHandler.h RequestManager.h SharedPtr.h SystemBackend.h Tokenizer.h
+ RequestHandler.h RequestManager.h SharedPtr.h SingletonPtr.h SystemBackend.h Tokenizer.h
all: all-recursive
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index e15ff67..3dfd1cf 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -30,7 +30,7 @@
namespace Mad {
namespace Common {
-RequestManager RequestManager::requestManager;
+SingletonPtr<RequestManager> RequestManager::requestManager;
RequestManager::RequestMap::~RequestMap() {
@@ -149,7 +149,7 @@ void RequestManager::unregisterPacketType(Net::Packet::Type type) {
requestHandlerFactories.erase(it);
}
-RequestManager::RequestManager() : core(false) {
+RequestManager::RequestManager() : core(false), requestId(-1) {
registerPacketType<RequestHandlers::DisconnectRequestHandler>(Net::Packet::DISCONNECT);
}
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index 723e619..0bc8080 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -20,7 +20,7 @@
#ifndef MAD_COMMON_REQUESTMANAGER_H_
#define MAD_COMMON_REQUESTMANAGER_H_
-#include "Initializable.h"
+#include "SingletonPtr.h"
#include <Net/Connection.h>
#include <map>
@@ -32,7 +32,7 @@ namespace Common {
class RequestBase;
class RequestHandler;
-class RequestManager : public Initializable {
+class RequestManager {
private:
class RequestMap : private std::map<uint16_t,RequestHandler*> {
private:
@@ -65,7 +65,7 @@ class RequestManager : public Initializable {
}
};
- static RequestManager requestManager;
+ static SingletonPtr<RequestManager> requestManager;
std::map<Net::Connection*,RequestMap*> requestMaps;
bool core;
@@ -81,19 +81,24 @@ class RequestManager : public Initializable {
RequestManager(const RequestManager &o);
RequestManager& operator=(const RequestManager &o);
- RequestManager();
-
void receiveHandler(Net::Connection *connection, const Net::Packet &packet);
public:
static RequestManager* get() {
- return &requestManager;
+ return requestManager.get();
}
+ RequestManager();
+
bool isCore() const {return core;}
- void setCore(bool newCore) {core = newCore;}
+ void setCore(bool newCore) {
+ core = newCore;
- virtual void doInit() {requestId = core ? -2 : -1;}
+ if(core)
+ requestId &= ~0x01;
+ else
+ requestId |= 0x01;
+ }
void registerConnection(Net::Connection *connection);
void unregisterConnection(Net::Connection *connection);
diff --git a/src/Common/SingletonPtr.h b/src/Common/SingletonPtr.h
new file mode 100644
index 0000000..ea4eda1
--- /dev/null
+++ b/src/Common/SingletonPtr.h
@@ -0,0 +1,63 @@
+/*
+ * SingletonPtr.h
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAD_COMMON_SINGLETONPTR_H_
+#define MAD_COMMON_SINGLETONPTR_H_
+
+#include "Initializable.h"
+
+namespace Mad {
+namespace Common {
+
+template <typename T>
+class SingletonPtr : public virtual Initializable {
+ private:
+ T *ptr;
+
+ protected:
+ virtual void doInit() {
+ if(ptr)
+ delete ptr;
+
+ ptr = new T();
+
+ Initializable *in = dynamic_cast<Initializable*>(ptr);
+ if(in)
+ in->init();
+ }
+
+ public:
+ SingletonPtr() : ptr(0) {}
+
+ virtual ~SingletonPtr() {
+ delete ptr;
+ }
+
+ T *get() {
+ if(!ptr)
+ init();
+
+ return ptr;
+ }
+};
+
+}
+}
+
+#endif /* MAD_COMMON_SINGLETONPTR_H_ */
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();
diff --git a/src/Net/ClientConnection.cpp b/src/Net/ClientConnection.cpp
index 25673fd..75a9ad6 100644
--- a/src/Net/ClientConnection.cpp
+++ b/src/Net/ClientConnection.cpp
@@ -98,7 +98,7 @@ void ClientConnection::connect(const IPAddress &address, bool daemon0) throw(Com
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t)sock);
- FdManager::getFdManager()->registerFd(sock, sigc::mem_fun(this, &Connection::sendReceive));
+ FdManager::get()->registerFd(sock, sigc::mem_fun(this, &Connection::sendReceive));
handshake();
}
diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp
index 5454dcf..7f8d9a9 100644
--- a/src/Net/Connection.cpp
+++ b/src/Net/Connection.cpp
@@ -288,7 +288,7 @@ void Connection::doDisconnect() {
if(!isConnected())
return;
- FdManager::getFdManager()->unregisterFd(sock);
+ FdManager::get()->unregisterFd(sock);
shutdown(sock, SHUT_RDWR);
close(sock);
@@ -304,7 +304,7 @@ void Connection::updateEvents() const {
if(state == HANDSHAKE || state == BYE)
events = ((gnutls_record_get_direction(session) == 0) ? POLLIN : POLLOUT);
- FdManager::getFdManager()->setFdEvents(sock, events);
+ FdManager::get()->setFdEvents(sock, events);
}
}
diff --git a/src/Net/FdManager.h b/src/Net/FdManager.h
index 1308a79..2e6fc66 100644
--- a/src/Net/FdManager.h
+++ b/src/Net/FdManager.h
@@ -44,7 +44,7 @@ class FdManager {
public:
virtual ~FdManager();
- static FdManager *getFdManager() {return &fdManager;}
+ static FdManager *get() {return &fdManager;}
bool registerFd(int fd, const sigc::slot<void, short> &handler, short events = 0);
bool unregisterFd(int fd);
diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp
index ed820d0..c4c5194 100644
--- a/src/Net/Listener.cpp
+++ b/src/Net/Listener.cpp
@@ -78,7 +78,7 @@ Listener::Listener(const std::string &x905CertFile0, const std::string &x905KeyF
throw Common::Exception("listen()", Common::Exception::INTERNAL_ERRNO, errno);
}
- FdManager::getFdManager()->registerFd(sock, sigc::mem_fun(this, &Listener::acceptHandler), POLLIN);
+ FdManager::get()->registerFd(sock, sigc::mem_fun(this, &Listener::acceptHandler), POLLIN);
}
Listener::~Listener() {
diff --git a/src/Net/ServerConnection.cpp b/src/Net/ServerConnection.cpp
index 05cc861..97e2ae4 100644
--- a/src/Net/ServerConnection.cpp
+++ b/src/Net/ServerConnection.cpp
@@ -73,7 +73,7 @@ ServerConnection::ServerConnection(int sock0, const IPAddress &address, gnutls_d
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred);
gnutls_transport_set_ptr(session, (gnutls_transport_ptr_t)sock);
- FdManager::getFdManager()->registerFd(sock, sigc::mem_fun(this, &Connection::sendReceive));
+ FdManager::get()->registerFd(sock, sigc::mem_fun(this, &Connection::sendReceive));
handshake();
}
diff --git a/src/mad.cpp b/src/mad.cpp
index 54b25d0..4a4b405 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -47,7 +47,6 @@ int main() {
Common::ConfigManager::get()->finish();
- 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);
Common::RequestManager::get()->registerPacketType<Daemon::RequestHandlers::CommandRequestHandler>(Net::Packet::COMMAND_REBOOT);
@@ -62,7 +61,7 @@ int main() {
connection->connect(Net::IPAddress("127.0.0.1"), true);
while(connection->isConnecting())
- Net::FdManager::getFdManager()->run();
+ Net::FdManager::get()->run();
Common::RequestManager::get()->registerConnection(connection);
@@ -76,7 +75,7 @@ int main() {
Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Daemon::Requests::IdentifyRequest("test", sigc::ptr_fun(requestFinished))));
while(connection->isConnected())
- Net::FdManager::getFdManager()->run();
+ Net::FdManager::get()->run();
Common::LogManager::get()->unregisterLogger(networkLogger);
diff --git a/src/madc.cpp b/src/madc.cpp
index 7397972..5dcb6ad 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -54,7 +54,7 @@ static void handleCommand(char *cmd) {
if(Client::CommandManager::get()->requestsActive()) {
rl_callback_handler_remove();
- Net::FdManager::getFdManager()->setFdEvents(STDIN_FILENO, 0);
+ Net::FdManager::get()->setFdEvents(STDIN_FILENO, 0);
}
}
@@ -68,7 +68,7 @@ static void activateReadline() {
return;
rl_callback_handler_install("mad> ", handleCommand);
- Net::FdManager::getFdManager()->setFdEvents(STDIN_FILENO, POLLIN);
+ Net::FdManager::get()->setFdEvents(STDIN_FILENO, POLLIN);
}
int main(int argc, char *argv[]) {
@@ -79,11 +79,10 @@ int main(int argc, char *argv[]) {
Net::Connection::init();
- Common::LogManager::get()->init();
+ Common::LogManager::get();
Common::ConfigManager::get()->finish();
- Common::RequestManager::get()->init();
Net::ClientConnection *connection = new Net::ClientConnection;
try {
@@ -92,7 +91,7 @@ int main(int argc, char *argv[]) {
std::cerr << "Connecting to " << argv[1] << "..." << std::flush;
while(connection->isConnecting())
- Net::FdManager::getFdManager()->run();
+ Net::FdManager::get()->run();
std::cerr << " connected." << std::endl;
@@ -100,25 +99,24 @@ int main(int argc, char *argv[]) {
std::cerr << "Receiving host list..." << std::flush;
- Client::InformationManager::get()->init();
Client::InformationManager::get()->updateDaemonList(connection);
while(Client::InformationManager::get()->isUpdating())
- Net::FdManager::getFdManager()->run();
+ Net::FdManager::get()->run();
std::cerr << " done." << std::endl << std::endl;
Client::CommandParser::get()->setConnection(connection);
Client::CommandManager::get()->signalFinished().connect(sigc::ptr_fun(activateReadline));
- Net::FdManager::getFdManager()->registerFd(STDIN_FILENO, sigc::ptr_fun(charHandler));
+ Net::FdManager::get()->registerFd(STDIN_FILENO, sigc::ptr_fun(charHandler));
activateReadline();
while(connection->isConnected())
- Net::FdManager::getFdManager()->run();
+ Net::FdManager::get()->run();
- Net::FdManager::getFdManager()->unregisterFd(STDIN_FILENO);
+ Net::FdManager::get()->unregisterFd(STDIN_FILENO);
Common::RequestManager::get()->unregisterConnection(connection);
}