Merge pull request #3097 from kfeuz/server_memory_leak

Server check for dead clients while checking for available messages
This commit is contained in:
Ben Fry
2015-02-21 13:45:45 -05:00
@@ -220,6 +220,16 @@ public class Server implements Runnable {
for (int i = 0; i < clientCount; i++) {
int which = (index + i) % clientCount;
Client client = clients[which];
//Check for valid client
if (!client.active()){
removeIndex(which); //Remove dead client
i--; //Don't skip the next client
//If the client has data make sure lastAvailable
//doesn't end up skipping the next client
which--;
//fall through to allow data from dead clients
//to be retreived.
}
if (client.available() > 0) {
lastAvailable = which;
return client;