[api] Fix ESP8266 noise API handshake deadlock and prompt socket cleanup (#13972)

This commit is contained in:
J. Nick Koston
2026-02-12 18:20:58 -06:00
committed by GitHub
parent 7dff631dcb
commit e0c03b2dfa
2 changed files with 12 additions and 6 deletions
+6 -2
View File
@@ -148,12 +148,16 @@ void APIServer::loop() {
while (client_index < this->clients_.size()) {
auto &client = this->clients_[client_index];
// Common case: process active client
if (!client->flags_.remove) {
client->loop();
}
// Handle disconnection promptly - close socket to free LWIP PCB
// resources and prevent retransmit crashes on ESP8266.
if (client->flags_.remove) {
// Rare case: handle disconnection (don't increment - swapped element needs processing)
this->remove_client_(client_index);
} else {
// Common case: process active client
client->loop();
client_index++;
}
}