RFR: 8304065: HttpServer.stop should terminate immediately if no exchanges are in progress

Daniel Fuchs dfuchs at openjdk.org
Tue May 20 18:14:54 UTC 2025


On Tue, 20 May 2025 15:51:50 GMT, Mikhail Yankelevich <myankelevich at openjdk.org> wrote:

> HttpServer::stop will terminate the server immidiately after all exhcnages are complete.
> If the exchanges take longer then the specified delay it will terminate straight after the delay, the same as the previous behaviour.
> 
> Used to wait until the delay is complete at all times, regardless of the number of active exchanges.
> 
> Tests based on @eirbjo work, so adding Eirik as a contributor.

Looking at Dispatcher::run - there are a couple of additional places where we should take into account the `finished` flag.
I wonder if we should stop processing events as soon as the `finished` has been set by one event. That would mean testing for `finished` right after calling `handleEvent` - or change `handleEvent` to return a boolean, and exit out of the while loop and close the selector if we have set `finished`. 
Arguably - maybe there should not be any event in the queue after `finished` has been set - but there doesn't seem any valid reason to `reRegister` connections or call `select(1000)` again at that point.

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

PR Comment: https://git.openjdk.org/jdk/pull/25333#issuecomment-2895386493


More information about the net-dev mailing list