From ce10864739759813d7376e447fae96abef23598d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 7 Sep 2008 21:39:11 +0200 Subject: Einige Vereinfachungen und Bugfixes --- src/Core/ConnectionManager.cpp | 44 +++++++++++++----------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) (limited to 'src/Core/ConnectionManager.cpp') 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::iterator con = daemonConnections.begin(); con != daemonConnections.end();) { +void ConnectionManager::handleConnections(std::list& connections) { + for(std::list::iterator con = connections.begin(); con != connections.end();) { if((*con)->isConnected()) { std::map::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::iterator con = clientConnections.begin(); con != clientConnections.end();) { - if((*con)->isConnected()) { - std::map::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::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); } } -- cgit v1.2.3