GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||
GeezerVison is showing github.com — Arm force-close timeout when an inbound CLOSE frame is echoed by normanmaurer · Pull Request #17574 · netty/netty Conversation
Member
Motivation: WebSocketServerProtocolHandler.decode() writes the CLOSE echo directly Modifications: Arm the timeout explicitly after the echo write is issued, and also Result: Awalys close the channel even when the remote peer stops reading
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsMotivation: WebSocketServerProtocolHandler.decode() writes the CLOSE echo directly via WebSocketServerHandshaker.close(), bypassing this handler's own write()/close() overrides where forceCloseTimeoutMillis was armed. If the peer stops draining its socket, the echo write never completes and the channel, its file descriptor and buffers are pinned forever. Modifications: Arm the timeout explicitly after the echo write is issued, and also from a new flush() override so a bare write(CloseWebSocketFrame) not followed by close() gets the same protection. The timeout is applied after the write/flush attempt, not before, so a write that completes synchronously never races the deadline. Result: Awalys close the channel even when the remote peer stops reading
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. A bare write(CloseWebSocketFrame) with no subsequent close() call never attached a listener that would close the channel once the force-close timeout failed closeSent, so the deadline had no effect on that path even though it fired. Have the timeout task close the channel itself instead of relying on other code paths to do so.
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
chrisvest
reviewed
Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. An application-initiated close (via ctx.close(), which arms the force-close deadline) can race with the peer's own CLOSE frame arriving concurrently. decode() unconditionally called closeSent(), silently replacing the field. Since the scheduled deadline task reads the closeSent field rather than a captured promise, it would then watch the wrong promise, leaving the original caller's close promise hanging forever. closeSent() now cascades onto the existing promise instead of replacing it when one is already in flight, so both promises complete once the deadline fires.
chrisvest
approved these changes
|
There was an error while loading. Please reload this page.
🚨 TestLens detected 1 failed test 🚨Here is what you can do:
Test SummaryBuild PR / macos-aarch64-java11-boringssl build > Netty/Transport/Native/KQueue
🏷️ Commit: dd650fb Test FailuresKQueueDatagramUnicastIPv6MappedTest > testSimpleSendCompositeMixedByteBuf(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-aarch64-java11-boringssl build)Rerun ControlsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Could not create auto-port PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Could not create auto-port PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ed (#17574) (#17712) Motivation: WebSocketServerProtocolHandler.decode() writes the CLOSE echo directly via WebSocketServerHandshaker.close(), bypassing this handler's own write()/close() overrides where forceCloseTimeoutMillis was armed. If the peer stops draining its socket, the echo write never completes and the channel, its file descriptor and buffers are pinned forever. Modifications: Arm the timeout explicitly after the echo write is issued, and also from a new flush() override so a bare write(CloseWebSocketFrame) not followed by close() gets the same protection. The timeout is applied after the write/flush attempt, not before, so a write that completes synchronously never races the deadline. Result: Awalys close the channel even when the remote peer stops reading
…ed (#17574) (#17710) Motivation: WebSocketServerProtocolHandler.decode() writes the CLOSE echo directly via WebSocketServerHandshaker.close(), bypassing this handler's own write()/close() overrides where forceCloseTimeoutMillis was armed. If the peer stops draining its socket, the echo write never completes and the channel, its file descriptor and buffers are pinned forever. Modifications: Arm the timeout explicitly after the echo write is issued, and also from a new flush() override so a bare write(CloseWebSocketFrame) not followed by close() gets the same protection. The timeout is applied after the write/flush attempt, not before, so a write that completes synchronously never races the deadline. Result: Awalys close the channel even when the remote peer stops reading
…already done" (#17983) Motivation: Since #17574, `WebSocketProtocolHandler.closeSent(promise)` cascades the outcome of an already recorded close promise onto the new one. When the server initiates the close handshake by writing a `CloseWebSocketFrame` and the peer responds with its own close frame, `WebSocketServerProtocolHandler.decode()` creates a new promise, passes it to `closeSent()` and then to `WebSocketServerHandshaker.close()`. As our own close frame was already written, the new promise is completed immediately, so the write in `close()` fails with `IllegalArgumentException: promise already done` and the close handshake fails. Modification: If a close frame was already sent (or is still being sent) when a close frame is received, don't echo another close frame (as required by RFC 6455) but close the connection once our own close frame was written. The force-close timeout still applies. Add tests for a server-initiated close handshake, including the reproducer from the issue, and adjust the simultaneous close test as no second close frame is written anymore. Result: Fixes #17776. A server-initiated WebSocket close handshake completes correctly again.
…already done" (#17983) (#18034) Motivation: Since #17574, `WebSocketProtocolHandler.closeSent(promise)` cascades the outcome of an already recorded close promise onto the new one. When the server initiates the close handshake by writing a `CloseWebSocketFrame` and the peer responds with its own close frame, `WebSocketServerProtocolHandler.decode()` creates a new promise, passes it to `closeSent()` and then to `WebSocketServerHandshaker.close()`. As our own close frame was already written, the new promise is completed immediately, so the write in `close()` fails with `IllegalArgumentException: promise already done` and the close handshake fails. Modification: If a close frame was already sent (or is still being sent) when a close frame is received, don't echo another close frame (as required by RFC 6455) but close the connection once our own close frame was written. The force-close timeout still applies. Add tests for a server-initiated close handshake, including the reproducer from the issue, and adjust the simultaneous close test as no second close frame is written anymore. Result: Fixes #17776. A server-initiated WebSocket close handshake completes correctly again. (cherry picked from commit 7a6f630)
…already done" (#17983) (#18032) Motivation: Since #17574, `WebSocketProtocolHandler.closeSent(promise)` cascades the outcome of an already recorded close promise onto the new one. When the server initiates the close handshake by writing a `CloseWebSocketFrame` and the peer responds with its own close frame, `WebSocketServerProtocolHandler.decode()` creates a new promise, passes it to `closeSent()` and then to `WebSocketServerHandshaker.close()`. As our own close frame was already written, the new promise is completed immediately, so the write in `close()` fails with `IllegalArgumentException: promise already done` and the close handshake fails. Modification: If a close frame was already sent (or is still being sent) when a close frame is received, don't echo another close frame (as required by RFC 6455) but close the connection once our own close frame was written. The force-close timeout still applies. Add tests for a server-initiated close handshake, including the reproducer from the issue, and adjust the simultaneous close test as no second close frame is written anymore. Result: Fixes #17776. A server-initiated WebSocket close handshake completes correctly again. (cherry picked from commit 7a6f630)
…ed (netty#17574) (netty#17710) Motivation: WebSocketServerProtocolHandler.decode() writes the CLOSE echo directly via WebSocketServerHandshaker.close(), bypassing this handler's own write()/close() overrides where forceCloseTimeoutMillis was armed. If the peer stops draining its socket, the echo write never completes and the channel, its file descriptor and buffers are pinned forever. Modifications: Arm the timeout explicitly after the echo write is issued, and also from a new flush() override so a bare write(CloseWebSocketFrame) not followed by close() gets the same protection. The timeout is applied after the write/flush attempt, not before, so a write that completes synchronously never races the deadline. Result: Awalys close the channel even when the remote peer stops reading
…already done" (netty#17983) (netty#18032) Motivation: Since netty#17574, `WebSocketProtocolHandler.closeSent(promise)` cascades the outcome of an already recorded close promise onto the new one. When the server initiates the close handshake by writing a `CloseWebSocketFrame` and the peer responds with its own close frame, `WebSocketServerProtocolHandler.decode()` creates a new promise, passes it to `closeSent()` and then to `WebSocketServerHandshaker.close()`. As our own close frame was already written, the new promise is completed immediately, so the write in `close()` fails with `IllegalArgumentException: promise already done` and the close handshake fails. Modification: If a close frame was already sent (or is still being sent) when a close frame is received, don't echo another close frame (as required by RFC 6455) but close the connection once our own close frame was written. The force-close timeout still applies. Add tests for a server-initiated close handshake, including the reproducer from the issue, and adjust the simultaneous close test as no second close frame is written anymore. Result: Fixes netty#17776. A server-initiated WebSocket close handshake completes correctly again. (cherry picked from commit 7a6f630)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.