Set<Object> idsToRemove = new HashSet<Object>();
for (ConnectionEntry entry : connections.values())
{
RemotingConnection conn = entry.connection;
boolean flush = true;
if (entry.ttl != -1)
{
if (!conn.checkDataReceived())
{
if (now >= entry.lastCheck + entry.ttl)
{
idsToRemove.add(conn.getID());
flush = false;
}
}
else
{
entry.lastCheck = now;
}
}
if (flush)
{
conn.flush();
}
}
for (Object id : idsToRemove)
{
RemotingConnection conn = removeConnection(id);
if (conn != null)
{
conn.fail(HornetQMessageBundle.BUNDLE.clientExited(conn.getRemoteAddress()));
}
}
if (latch.await(pauseInterval, TimeUnit.MILLISECONDS))
return;