const auto interval = immutable.d_tcpConnectionsRatePerClientInterval;
const auto cutOff = static_cast<time_t>(now - (interval * 60U)); // interval in minutes
for (auto& shard : s_tcpClientsConnectionMetrics) {
- auto db = shard.lock();
- auto& index = db->get<TimeTag>();
+ auto clients = shard.lock();
+ auto& index = clients->get<TimeTag>();
for (auto entry = index.begin(); entry != index.end();) {
+ if (entry->d_concurrentConnections > 0) {
+ /* we need to keep this around as we still have open connections */
+ ++entry;
+ continue;
+ }
if (entry->d_lastSeen >= cutOff) {
/* this index is ordered on timestamps,
so the first valid entry we see means we are done */