Skip to content

Commit

Permalink
Merge pull request #30 from ESP32Async/issues/ws-cleanup
Browse files Browse the repository at this point in the history
fix(ws): break loop after erasing client
  • Loading branch information
mathieucarbou authored Jan 28, 2025
2 parents 7be1742 + 180b850 commit 9bdefb8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/AsyncWebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,11 +916,10 @@ void AsyncWebSocket::cleanupClients(uint16_t maxClients) {
_clients.front().close();
}

for (auto iter = std::begin(_clients); iter != std::end(_clients);) {
if (iter->shouldBeDeleted()) {
iter = _clients.erase(iter);
} else {
iter++;
for (auto i = _clients.begin(); i != _clients.end(); ++i) {
if (i->shouldBeDeleted()) {
_clients.erase(i);
break;
}
}
}
Expand Down

0 comments on commit 9bdefb8

Please sign in to comment.