summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Net/Listener.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp
index b981b20..3fb2415 100644
--- a/src/Net/Listener.cpp
+++ b/src/Net/Listener.cpp
@@ -84,8 +84,16 @@ ServerConnection* Listener::getConnection() {
addrlen = sizeof(sa);
}
- for(std::list<ServerConnection*>::iterator con = connections.begin(); con != connections.end(); con++) {
+ for(std::list<ServerConnection*>::iterator con = connections.begin(); con != connections.end(); ++con)
(*con)->sendReceive();
+
+ for(std::list<ServerConnection*>::iterator con = connections.begin(); con != connections.end();) {
+ if(!(*con)->isConnected()) {
+ delete *con;
+ connections.erase(con++); // Erase unincremented iterator
+
+ continue;
+ }
if(!(*con)->isConnecting()) {
ServerConnection *connection = *con;
@@ -93,6 +101,8 @@ ServerConnection* Listener::getConnection() {
return connection;
}
+
+ ++con;
}
return 0;