Skip to content

Commit

Permalink
Bugfix: stale HTTP connections may get missed in cleanInactive meth…
Browse files Browse the repository at this point in the history
…od (#2741)

This PR fixes the `cleanInactive` method.

By code inspection if a stale connection is deleted from the list then the loop index is increment, skipping over the next item.
  • Loading branch information
mikee47 authored Mar 22, 2024
1 parent fdbc1f0 commit dc7d3fa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sming/Components/Network/src/Network/HttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ void HttpClient::cleanInactive()
{
debug_d("Total connections: %d", httpConnectionPool.count());

for(size_t i = 0; i < httpConnectionPool.count(); i++) {
size_t i = 0;
while(i < httpConnectionPool.count()) {
auto connection = httpConnectionPool.valueAt(i);

if(connection->getConnectionState() > eTCS_Connecting && !connection->isActive()) {
debug_d("Removing stale connection: State: %d, Active: %d, Finished: %d", connection->getConnectionState(),
connection->isActive(), connection->isFinished());
httpConnectionPool.removeAt(i);
} else {
++i;
}
}
}

0 comments on commit dc7d3fa

Please sign in to comment.