diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-09-07 21:39:11 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-09-07 21:39:11 +0200 |
commit | ce10864739759813d7376e447fae96abef23598d (patch) | |
tree | 3e4d9c732a6836dcfb66889fd204e1177800c518 /src/Core | |
parent | 7d5b81e9936b1c778fd6408f3f22478e9ab9486b (diff) | |
download | mad-ce10864739759813d7376e447fae96abef23598d.tar mad-ce10864739759813d7376e447fae96abef23598d.zip |
Einige Vereinfachungen und Bugfixes
Diffstat (limited to 'src/Core')
-rw-r--r-- | src/Core/ConnectionManager.cpp | 44 | ||||
-rw-r--r-- | src/Core/ConnectionManager.h | 2 |
2 files changed, 15 insertions, 31 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp index a537539..62eed53 100644 --- a/src/Core/ConnectionManager.cpp +++ b/src/Core/ConnectionManager.cpp @@ -62,7 +62,7 @@ ConnectionManager::ConnectionManager(const ConfigManager& configManager) : reque listeners.push_back(new Net::Listener(configManager.getX509CertFile(), configManager.getX509KeyFile())); } catch(Net::Exception &e) { - // TODO: Log error + // TODO Log error } } else { @@ -71,10 +71,11 @@ ConnectionManager::ConnectionManager(const ConfigManager& configManager) : reque listeners.push_back(new Net::Listener(configManager.getX509CertFile(), configManager.getX509KeyFile(), *address)); } catch(Net::Exception &e) { - // TODO: Log error + // TODO Log error } } } + refreshPollfds(); } @@ -86,10 +87,8 @@ ConnectionManager::~ConnectionManager() { delete *con; } -void ConnectionManager::run() { - // TODO: Logging - - for(std::list<Net::ServerConnection*>::iterator con = daemonConnections.begin(); con != daemonConnections.end();) { +void ConnectionManager::handleConnections(std::list<Net::ServerConnection*>& connections) { + for(std::list<Net::ServerConnection*>::iterator con = connections.begin(); con != connections.end();) { if((*con)->isConnected()) { std::map<int,const short*>::iterator events = pollfdMap.find((*con)->getSocket()); @@ -103,40 +102,23 @@ void ConnectionManager::run() { else { requestManager.unregisterConnection(*con); delete *con; - daemonConnections.erase(con++); + connections.erase(con++); } } +} - for(std::list<Net::ServerConnection*>::iterator con = clientConnections.begin(); con != clientConnections.end();) { - if((*con)->isConnected()) { - std::map<int,const short*>::iterator events = pollfdMap.find((*con)->getSocket()); - - if(events != pollfdMap.end()) - (*con)->sendReceive(*events->second); - else - (*con)->sendReceive(); +void ConnectionManager::run() { + // TODO Logging - ++con; - } - else { - requestManager.unregisterConnection(*con); - delete *con; - clientConnections.erase(con++); - } - } + handleConnections(daemonConnections); + handleConnections(clientConnections); for(std::list<Net::Listener*>::iterator listener = listeners.begin(); listener != listeners.end(); ++listener) { Net::ServerConnection *con; while((con = (*listener)->getConnection(pollfdMap)) != 0) { - if(con->isDaemonConnection()) { - daemonConnections.push_back(con); - requestManager.registerConnection(con); - } - else { - clientConnections.push_back(con); - requestManager.registerConnection(con); - } + (con->isDaemonConnection() ? daemonConnections : clientConnections).push_back(con); + requestManager.registerConnection(con); } } diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h index 7429a44..6161c3f 100644 --- a/src/Core/ConnectionManager.h +++ b/src/Core/ConnectionManager.h @@ -57,6 +57,8 @@ class ConnectionManager { void refreshPollfds(); + void handleConnections(std::list<Net::ServerConnection*>& connections); + public: ConnectionManager(const ConfigManager& configManager); virtual ~ConnectionManager(); |