-
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 shutdown of non-persistent HTTP/1 connections #12212 #12216
Conversation
+ shutdown in SendCallback + keep failsafe in Stream callback + improve chunk toString clarity + added failsafe release in onFillable, to handle case when endpoint is closed.
@lachlan-roberts @sbordet @lorban This work builds on #12213 by moving the shutdownOutput to the SendCallback, rather than wait for the Stream callback completion (which may be long after the response is completed). Whilst working on this, I noticed that onFillable could exit without releasing the request buffer. So I've added a failsafe release. However, it would be good to review the release logic of the class as part of the review of this PR. I believe this change may help with the HTTP/0.9 issues we have seen |
+ shutdown in SendCallback + keep failsafe in Stream callback + improve chunk toString clarity + added failsafe release in onFillable, to handle case when endpoint is closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gregw I fail to exactly understand what this PR is fixing.
Is there a new test case to be added, or an existing one that fails?
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/internal/ByteBufferChunk.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/AbstractRetainableByteBuffer.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
Did you read #12212 where it says:
So this is really just reverting to the behaviour that we've had for decades.
I've written a test to check that the shutdown by a write(last) is not delayed until after callback.succeeded on the handle callback. |
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code wise, I believe this change is good.
But the biggest issue here is IMHO that the difference between the last write and succeeding the callback is a bit tricky to implement and may need to be better javadoc'ed.
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/internal/HttpConnection.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java
Show resolved
Hide resolved
@sbordet @lorban fixing the buffer release in HttpConnection proved to be a game of whack-a-bug! The problems with release include:
I think it is all mostly working, but it is fragile to changes. I think it needs a bit more time to review and perhaps a big catchall release called when the stream is completed (i.e. after both succeed/fail AND the last write has completed AND the handler thread has returned). |
* Removed unnecessary release of buffer in case -1 is read. * Removed failsafe shutdown output from HttpStreamOverHTTP1.succeeded() now that is done by ContentSender.onCompleteSuccess(). * Rewritten HttpServerTestBase.testCloseWhileCompletePending using HttpTester. Signed-off-by: Simone Bordet <[email protected]>
Signed-off-by: Simone Bordet <[email protected]>
Just improving the test code. The flakyness was likely fixed by the work in #12216 and #12237. Signed-off-by: Simone Bordet <[email protected]>
Just improving the test code. The flakyness was likely fixed by the work in #12216 and #12237. Signed-off-by: Simone Bordet <[email protected]>
Fix #12212 by improving shutdown of non-persistent HTTP/1 connections