RFR: 8300268 : ServerImpl allows too many idle connections when using sun.net.httpserver.maxIdleConnections
Vyom Tewari
vtewari at openjdk.org
Tue Feb 7 07:16:45 UTC 2023
On Fri, 3 Feb 2023 17:58:28 GMT, Darragh Clarke <duke at openjdk.org> wrote:
> Currently there is a race condition that can allow for too many 'idleConnections' in `ServerImpl`
>
> This PR adds a lock to make sure only one connection can be marked Idle at a time as well as a test that consistently failed before the change but which now passes.
src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java line 966:
> 964:
> 965: void markIdle(HttpConnection c) {
> 966: Boolean close = false;
I did not go deep but i am not sure removing the connections is right thing to do in "markIdle". i see test is failing if i increase the totalConnections = maxIdleConnections + 5;.
----------System.out:(39/2387)----------
Server started at address /[127.0.0.1:38135](http://127.0.0.1:38135/)
Issuing request http://127.0.0.1:38135/MaxIdleConnectionTest/1
Issuing request http://127.0.0.1:38135/MaxIdleConnectionTest/2
Issuing request http://127.0.0.1:38135/MaxIdleConnectionTest/3
Issuing request http://127.0.0.1:38135/MaxIdleConnectionTest/4
Issuing request http://127.0.0.1:38135/MaxIdleConnectionTest/6
Issuing request http://127.0.0.1:38135/MaxIdleConnectionTest/5
Issuing request http://127.0.0.1:38135/MaxIdleConnectionTest/8
Issuing request http://127.0.0.1:38135/MaxIdleConnectionTest/7
Issuing request http://127.0.0.1:38135/MaxIdleConnectionTest/9
Waiting for all 9 requests to reach the server side request handler
Request /MaxIdleConnectionTest/2 received; handler will wait on latch
Request /MaxIdleConnectionTest/1 received; handler will wait on latch
Request /MaxIdleConnectionTest/3 received; handler will wait on latch
Request /MaxIdleConnectionTest/7 received; handler will wait on latch
Request /MaxIdleConnectionTest/6 received; handler will wait on latch
Request /MaxIdleConnectionTest/8 received; handler will wait on latch
Request /MaxIdleConnectionTest/9 received; handler will wait on latch
Request /MaxIdleConnectionTest/5 received; handler will wait on latch
Sending response for request /MaxIdleConnectionTest/1 from /[127.0.0.1:59710](http://127.0.0.1:59710/)
Request /MaxIdleConnectionTest/4 received; handler will wait on latch
Sending response for request /MaxIdleConnectionTest/2 from /[127.0.0.1:59724](http://127.0.0.1:59724/)
Sending response for request /MaxIdleConnectionTest/4 from /[127.0.0.1:59734](http://127.0.0.1:59734/)
Sending response for request /MaxIdleConnectionTest/6 from /[127.0.0.1:59712](http://127.0.0.1:59712/)
Sending response for request /MaxIdleConnectionTest/5 from /[127.0.0.1:59748](http://127.0.0.1:59748/)
Sending response for request /MaxIdleConnectionTest/8 from /[127.0.0.1:59766](http://127.0.0.1:59766/)
Sending response for request /MaxIdleConnectionTest/3 from /[127.0.0.1:59760](http://127.0.0.1:59760/)
Sending response for request /MaxIdleConnectionTest/7 from /[127.0.0.1:59774](http://127.0.0.1:59774/)
Sending response for request /MaxIdleConnectionTest/9 from /[127.0.0.1:59752](http://127.0.0.1:59752/)
Received successful response for request 0
Received successful response for request 1
Received successful response for request 2
Received successful response for request 3
Received successful response for request 4
Received successful response for request 5
Received successful response for request 6
Received successful response for request 7
Received successful response for request 8
count 2
Note: Modified and original both test passes on jdk without your fix.
-------------
PR: https://git.openjdk.org/jdk/pull/12413
More information about the net-dev
mailing list