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.cpp44
1 files changed, 13 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);
}
}