RFR: 8293562: blocked threads with KeepAliveCache.get [v2]

Daniel Fuchs dfuchs at openjdk.org
Tue Sep 27 13:16:24 UTC 2022


On Tue, 27 Sep 2022 09:18:18 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

>> Please review this patch that makes sure KeepAliveCache does not block all threads while closing sockets.
>> 
>> Changes:
>> - get operation no longer closes sockets; if there's no socket that is recent enough, get returns null and lets the cleaner thread close the sockets
>> - put operation closes sockets without holding the cache lock. Additionally, if the cache is full, it places the new connection in the cache and removes the oldest connection.
>> - the cleaner thread creates a list of connections to close, and then closes them after releasing the cache lock
>> - additionally, we set the socket timeout to 1 millisecond before calling socket.close
>> 
>> The new test fails with `Wait for second request timed out` without this patch, passes after the changes. Tiers 1-3 clean.
>
> Daniel Jeliński has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Only set timeout on SSLSockets

test/jdk/sun/net/www/http/KeepAliveCache/B8293562.java line 73:

> 71: 
> 72:     public static void startHttpServer() throws Exception {
> 73:         server = HttpServer.create(new InetSocketAddress(InetAddress.getLocalHost(), 0), 10);

It would probably be better to use the loopback - if there's no  particular reason to use the local host name?

test/jdk/sun/net/www/http/KeepAliveCache/B8293562.java line 81:

> 79:         try {
> 80:             System.out.println("http server listen on: " + server.getAddress().getPort());
> 81:             String hostAddr =  InetAddress.getLocalHost().getHostAddress();

same here...

-------------

PR: https://git.openjdk.org/jdk/pull/10401


More information about the net-dev mailing list