summaryrefslogtreecommitdiffstats
path: root/src/Core/ConnectionManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/ConnectionManager.cpp')
-rw-r--r--src/Core/ConnectionManager.cpp45
1 files changed, 7 insertions, 38 deletions
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 <Net/FdManager.h>
#include <Net/ServerConnection.h>
#include <Net/Packet.h>
#include <Net/Listener.h>
@@ -43,30 +44,6 @@ namespace Core {
std::auto_ptr<ConnectionManager> ConnectionManager::connectionManager;
-void ConnectionManager::refreshPollfds() {
- pollfds.clear();
- pollfdMap.clear();
-
- for(std::list<Net::Listener*>::iterator listener = listeners.begin(); listener != listeners.end(); ++listener) {
- std::vector<struct pollfd> fds = (*listener)->getPollfds();
-
- for(std::vector<struct pollfd>::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<Net::ServerConnection*>::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<Net::ServerConnection*>::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<Common::HostInfo>& daemons = configManager->getDaemonList();
for(std::vector<Common::HostInfo>::const_iterator daemon = daemons.begin(); daemon != daemons.end(); ++daemon) {
@@ -138,15 +113,7 @@ ConnectionManager::~ConnectionManager() {
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());
-
- if(events != pollfdMap.end() && *events->second)
- (*con)->sendReceive(*events->second);
-
- ++con;
- }
- else {
+ if(!(*con)->isConnected()) {
if((*con)->isIdentified()) {
for(std::map<std::string,Net::ServerConnection*>::iterator idCon = identifiedDaemonConnections.begin(); idCon != identifiedDaemonConnections.end(); ++idCon) {
if(idCon->second == *con) {
@@ -162,25 +129,27 @@ void ConnectionManager::handleConnections(std::list<Net::ServerConnection*>& con
delete *con;
connections.erase(con++);
}
+ else
+ ++con;
}
}
void ConnectionManager::run() {
// TODO Logging
+ Net::FdManager::getFdManager()->run();
+
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) {
+ 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&) {