From fcab8098d6a9a385e0e5edfb26f4abf615da77ca Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 10 Oct 2008 15:04:28 +0200 Subject: FdManager hinzugef?gt und Verbindungsklassen angepasst --- src/Core/ConnectionManager.cpp | 45 +++++++----------------------------------- 1 file changed, 7 insertions(+), 38 deletions(-) (limited to 'src/Core/ConnectionManager.cpp') diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp index a41b024..c0edd61 100644 --- a/src/Core/ConnectionManager.cpp +++ b/src/Core/ConnectionManager.cpp @@ -30,6 +30,7 @@ #include "RequestHandlers/GSSAPIAuthRequestHandler.h" #include "RequestHandlers/IdentifyRequestHandler.h" #include "RequestHandlers/LogRequestHandler.h" +#include #include #include #include @@ -43,30 +44,6 @@ namespace Core { std::auto_ptr ConnectionManager::connectionManager; -void ConnectionManager::refreshPollfds() { - pollfds.clear(); - pollfdMap.clear(); - - for(std::list::iterator listener = listeners.begin(); listener != listeners.end(); ++listener) { - std::vector fds = (*listener)->getPollfds(); - - for(std::vector::iterator fd = fds.begin(); fd != fds.end(); ++fd) { - pollfds.push_back(*fd); - pollfdMap.insert(std::make_pair(fd->fd, &pollfds.back().revents)); - } - } - - for(std::list::iterator con = daemonConnections.begin(); con != daemonConnections.end(); ++con) { - pollfds.push_back((*con)->getPollfd()); - pollfdMap.insert(std::make_pair(pollfds.back().fd, &pollfds.back().revents)); - } - - for(std::list::iterator con = clientConnections.begin(); con != clientConnections.end(); ++con) { - pollfds.push_back((*con)->getPollfd()); - pollfdMap.insert(std::make_pair(pollfds.back().fd, &pollfds.back().revents)); - } -} - void ConnectionManager::updateState(const std::string &name, Common::HostInfo::State state) { daemonInfo[name].setState(state); @@ -116,8 +93,6 @@ ConnectionManager::ConnectionManager() { } } - refreshPollfds(); - const std::vector& daemons = configManager->getDaemonList(); for(std::vector::const_iterator daemon = daemons.begin(); daemon != daemons.end(); ++daemon) { @@ -138,15 +113,7 @@ ConnectionManager::~ConnectionManager() { 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()); - - if(events != pollfdMap.end() && *events->second) - (*con)->sendReceive(*events->second); - - ++con; - } - else { + if(!(*con)->isConnected()) { if((*con)->isIdentified()) { for(std::map::iterator idCon = identifiedDaemonConnections.begin(); idCon != identifiedDaemonConnections.end(); ++idCon) { if(idCon->second == *con) { @@ -162,25 +129,27 @@ void ConnectionManager::handleConnections(std::list& con delete *con; connections.erase(con++); } + else + ++con; } } void ConnectionManager::run() { // TODO Logging + Net::FdManager::getFdManager()->run(); + handleConnections(daemonConnections); handleConnections(clientConnections); for(std::list::iterator listener = listeners.begin(); listener != listeners.end(); ++listener) { Net::ServerConnection *con; - while((con = (*listener)->getConnection(pollfdMap)) != 0) { + while((con = (*listener)->getConnection()) != 0) { (con->isDaemonConnection() ? daemonConnections : clientConnections).push_back(con); Common::RequestManager::getRequestManager()->registerConnection(con); } } - - refreshPollfds(); } Net::Connection* ConnectionManager::getDaemonConnection(const std::string &name) const throw (Common::Exception&) { -- cgit v1.2.3