-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve connection closing when stopping #12435
Comments
An idealized shutdown would be:
I think this is what we do when we are graceful? |
@gregw, currently:
So apparently bullet 2 should just be removed, as stopping all the beans happens in reverse order, and therefore contexts are stopped before the connectors. I'll try and prepare a PR about this to see what breaks. |
A further problem is that, per Servlet Specification, idle timeouts are ignored for suspended requests. This means if there is a suspended request (e.g. long poll), stopping the The next interaction with the application is when the |
Restored synchronous behavior for `HttpConnection.close()`. This allows to send a response for suspended requests while the server is being stopped. See also #12435. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Restored synchronous behavior for `HttpConnection.close()`. This allows to send a response for suspended requests while the server is being stopped. See also #12435. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Jetty version(s)
12
Description
When stopping a
Server
, theManagedSelector
is stopped (as part of being a descendant bean ofServer
).Currently,
ManagedSelector.doStop()
submits aCloseConnections
update, and then waits for it, then submits aStopSelector
update, and waits for it.Both these updates iterate over the keys to call
close()
, but likely theclose()
operation is asynchronous -- it certainly is in HTTP/2 where a GOAWAY frame is submitted to be written, but it is also in HTTP/1 after the changes in #12395.The idea would be to have a "pre-close" action, and we can use
Graceful
to shutdown and receive back aCompletableFuture
.So, the
CloseConnections
update would callshutdown()
on theConnection
, and theStopSelector
action would callEndPoint.close()
.This would allow for asynchronous actions to happen in
Connection.shutdown()
and be waited for byManagedSelector
, and forEndPoint.close()
to forcibly close.The alternative would be to make the action in
[HTTP1,2,3]Connection.close()
to be run synchronously, but it may block.The text was updated successfully, but these errors were encountered: