Skip to content

Commit

Permalink
Fixes #4904 - WebsocketClient creates more connections than needed.
Browse files Browse the repository at this point in the history
More fixes to the connection pool logic.
Now the connection close/removal aggressively sends more
requests triggering the connection creation.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed May 29, 2020
1 parent f33a12b commit 6e2429f
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -452,25 +452,27 @@ public void release(Connection connection)

public boolean remove(Connection connection)
{
return connectionPool.remove(connection);
}

public void close(Connection connection)
{
boolean removed = remove(connection);
boolean removed = connectionPool.remove(connection);

if (getHttpExchanges().isEmpty())
{
tryRemoveIdleDestination();
}
else
{
// We need to execute queued requests even if this connection failed.
// We may create a connection that is not needed, but it will eventually
// idle timeout, so no worries.
// We need to execute queued requests
// even if this connection was removed.
// We may create a connection that is not
// needed, but it will eventually idle timeout.
if (removed)
process(true);
}
return connectionPool.remove(connection);
}

public void close(Connection connection)
{
remove(connection);
}

/**
Expand Down

0 comments on commit 6e2429f

Please sign in to comment.