Skip to content
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

Release websocket handshake response if pipeline checks fail #13338

Merged
merged 1 commit into from Apr 20, 2023

Conversation

chrisvest
Copy link
Contributor

Motivation:
The WebSocketServerHandshaker require that either an HttpRequestDecoder or an HttpServerCodec exist in the pipeline. If they do not, we can't send a websocket handshake response. The handshake response is allocated prior to the pipeline checks. Therefor, if the checks fail, we need to release the response before returning the failed future.

It might be possible to delay the allocation of the response until after the pipeline checks, but doing so breaks assumptions made by numerous tests.

Modification:
If the pipeline checks fail, release the handshake response before returning the failed promise.

Result:
We no longer leak a buffer in the handshake response if the pipeline checks fail.

Fixes #13337

Motivation:
The WebSocketServerHandshaker require that either an HttpRequestDecoder or an HttpServerCodec exist in the pipeline.
If they do not, we can't send a websocket handshake response.
The handshake response is allocated prior to the pipeline checks.
Therefor, if the checks fail, we need to release the response before returning the failed future.

It might be possible to delay the allocation of the response until after the pipeline checks, but doing so breaks assumptions made by numerous tests.

Modification:
If the pipeline checks fail, release the handshake response before returning the failed promise.

Result:
We no longer leak a buffer in the handshake response if the pipeline checks fail.
@chrisvest chrisvest added this to the 4.1.92.Final milestone Apr 17, 2023
@hyperxpro
Copy link
Contributor

Why are we even creating it before checking for pipeline configuration?

@chrisvest
Copy link
Contributor Author

@hyperxpro I do not know, but there were multiple test failures if I just moved it.

@normanmaurer normanmaurer merged commit f2eca0f into netty:4.1 Apr 20, 2023
14 checks passed
normanmaurer pushed a commit that referenced this pull request Apr 20, 2023
Motivation:
The WebSocketServerHandshaker require that either an HttpRequestDecoder or an HttpServerCodec exist in the pipeline.
If they do not, we can't send a websocket handshake response.
The handshake response is allocated prior to the pipeline checks.
Therefor, if the checks fail, we need to release the response before returning the failed future.

It might be possible to delay the allocation of the response until after the pipeline checks, but doing so breaks assumptions made by numerous tests.

Modification:
If the pipeline checks fail, release the handshake response before returning the failed promise.

Result:
We no longer leak a buffer in the handshake response if the pipeline checks fail.
@chrisvest chrisvest deleted the 41-release-ws-hs-resp branch April 20, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebSocketServerHandshaker.handshake not call ByteBuf.release()
3 participants