From fb949bfd7687696c47449aaea0e6a117d382d41c Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 26 Jun 2008 01:40:24 +0200 Subject: Listener: Getrennte Verbindungen verwerfen --- src/Net/Listener.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') 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::iterator con = connections.begin(); con != connections.end(); con++) { + for(std::list::iterator con = connections.begin(); con != connections.end(); ++con) (*con)->sendReceive(); + + for(std::list::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; -- cgit v1.2.3