GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Make half-closure a core-concept of Channel by normanmaurer · Pull Request #15987 · netty/netty

Conversation

@normanmaurer

@normanmaurer normanmaurer commented Dec 8, 2025

Copy link
Copy Markdown
Member

Motivation:

At the moment our half-closure support is kind of weak and hacky. We use various DuplexChannel specific methods which will not traverse the pipeline at all and also use user events. This should be changed to be a "core concept" and so have dedicated methods that can be used and also traverse the pipeline.

What shutdown(...) actually means is a bit transport specific but in general once someone shutdown the output it should not be possible to write anymore. Also when the inbound is shutdown we should not propagate inbound messages anymore. If the shutdown calls are propagated through the network somehow is specific to the protocol itself and so might differ.

Modifications:

  • Add ChannelShutdownType and ChannelShutdownDirection
  • Add ChannelOutboundInvoker.shutdown(ChannelShutdownType, ChannelPromise) method
  • Add ChannelInboundInvoker.fireChannelShutdown(ChannelShutdownType) methods
  • Add Channel.isShutdown(ChannelShutdownType) method
  • Add ChannelHandler.shutdown(ChannelHandlerContext, ChannelShutdownType) and ChannelHandler.channelShutdown(ChannelHandlerContext, ChannelShutdownType) methods
  • Refactor code to use the new methods and also add implementations for the different transports

Result:

Half-closure is now a core-concept of netty.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

He-Pin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@normanmaurer

normanmaurer commented Dec 8, 2025

Copy link
Copy Markdown
Member Author

This is a enhanced port of d3cf5be#diff-e2e25bbd38bee644a31d741bafd563a8449ce27632e0c09720ccce66fbcae3f6

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
normanmaurer requested review from chrisvest and yawkat December 8, 2025 12:42
@normanmaurer
normanmaurer force-pushed the shutdown_core branch from f1fb30b to 1a37114 Compare December 8, 2025 12:56
@chrisvest

chrisvest commented Dec 8, 2025

Copy link
Copy Markdown
Member

Got an epoll test failure:

2025-12-08T13:54:38.8517096Z [ERROR] Tests run: 6, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 34.30 s <<< FAILURE! -- in io.netty.channel.epoll.EpollSocketHalfClosedTest
2025-12-08T13:54:38.8518883Z [ERROR] io.netty.channel.epoll.EpollSocketHalfClosedTest.testAllDataReadClosure(TestInfo) -- Time elapsed: 22.17 s <<< ERROR!
2025-12-08T13:54:38.8520780Z java.util.concurrent.TimeoutException: testAllDataReadClosure(org.junit.jupiter.api.TestInfo) timed out after 20000 milliseconds
2025-12-08T13:54:38.8526562Z 	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
2025-12-08T13:54:38.8527249Z 	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
2025-12-08T13:54:38.8527835Z 	Suppressed: java.lang.InterruptedException
2025-12-08T13:54:38.8529120Z 		at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1140)
2025-12-08T13:54:38.8530435Z 		at java.base/java.util.concurrent.CountDownLatch.await(CountDownLatch.java:230)
2025-12-08T13:54:38.8531606Z 		at io.netty.testsuite.transport.socket.SocketHalfClosedTest.testAllDataReadClosure(SocketHalfClosedTest.java:771)
2025-12-08T13:54:38.8533243Z 		at io.netty.testsuite.transport.socket.SocketHalfClosedTest.testAllDataReadClosure(SocketHalfClosedTest.java:679)
2025-12-08T13:54:38.8534547Z 		at io.netty.testsuite.transport.socket.SocketHalfClosedTest$16.run(SocketHalfClosedTest.java:672)
2025-12-08T13:54:38.8535820Z 		at io.netty.testsuite.transport.socket.SocketHalfClosedTest$16.run(SocketHalfClosedTest.java:669)
2025-12-08T13:54:38.8536999Z 		at io.netty.testsuite.transport.AbstractComboTestsuiteTest.run(AbstractComboTestsuiteTest.java:52)
2025-12-08T13:54:38.8538320Z 		at io.netty.testsuite.transport.socket.SocketHalfClosedTest.testAllDataReadClosure(SocketHalfClosedTest.java:669)
2025-12-08T13:54:38.8539388Z 		at java.base/java.lang.reflect.Method.invoke(Method.java:565)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Dec 8, 2025

Copy link
Copy Markdown
Member Author

Will check with devcontainers

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Dec 9, 2025

Copy link
Copy Markdown
Member Author

@chrisvest should be fixed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chrisvest
chrisvest reviewed Dec 9, 2025
View reviewed changes

@chrisvest chrisvest left a comment

Copy link
Copy Markdown
Member

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.

Had some comments

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicStreamChannel.java
}

if (write) {
ioTransport.writeWithoutCheckChannelState(QuicStreamFrame.EMPTY_FIN, newPromise()

@chrisvest chrisvest Dec 8, 2025

Copy link
Copy Markdown
Member

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.

Should we skip this and fail early if outputShutdown is already true? Similar for inbound.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@normanmaurer normanmaurer Dec 9, 2025

Copy link
Copy Markdown
Member Author

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.

we could ... I just ported the old code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@normanmaurer normanmaurer Dec 9, 2025

Copy link
Copy Markdown
Member Author

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.

I think we should not fail but just succeed them early. As even on a idk SocketChannel it will not throw in this case. ... done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread codec-http3/src/main/java/io/netty/handler/codec/http3/Http3ControlStreamInboundHandler.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread codec-http3/src/main/java/io/netty/handler/codec/http3/Http3RequestStreamInboundHandler.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread transport/src/main/java/io/netty/channel/AbstractChannel.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread transport/src/main/java/io/netty/channel/AbstractChannel.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread transport/src/main/java/io/netty/channel/AbstractChannel.java
ioTransport.closeOutboundBufferForShutdown(pipeline, outboundBuffer, shutdownCause);
outboundBuffer.failFlushedAndClose(shutdownCause, false, shutdownCause, true);
// TODO: Is this correct ?
pipeline().fireChannelShutdown(ChannelShutdownType.newOutbound());

@chrisvest chrisvest Dec 9, 2025

Copy link
Copy Markdown
Member

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.

We also do this in IoTransport.shutdown. Do we need to do this both places, or can we delegate?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@normanmaurer normanmaurer Dec 9, 2025

Copy link
Copy Markdown
Member Author

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.

yes in both places imho... But I would keep the code separate

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread transport/src/main/java/io/netty/channel/ChannelOutboundHandler.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Dec 9, 2025

Copy link
Copy Markdown
Member Author

@chrisvest addressed all your comments PTAL again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
normanmaurer requested a review from chrisvest December 9, 2025 02:12
@normanmaurer
normanmaurer force-pushed the shutdown_core branch from c687a6c to e162f49 Compare December 9, 2025 14:03
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Dec 9, 2025
@normanmaurer
normanmaurer force-pushed the shutdown_core branch from e162f49 to 341d4e7 Compare December 9, 2025 14:25
chrisvest
chrisvest approved these changes Dec 9, 2025
View reviewed changes
normanmaurer added 3 commits December 9, 2025 11:18
@normanmaurer
Make half-closure a core-concept of Channel (#12468)
46b7177
Motivation:

At the moment our half-closure support is kind of weak and hacky. We use various DuplexChannel specific methods which will not traverse the pipeline at all and also use user events. This should be changed to be a "core concept" and so have dedicated methods that can be used and also traverse the pipeline.

What shutdown(...) actually means is a bit transport specific but in general once someone shutdown the output it should not be possible to write anymore. Also when the inbound is shutdown we should not propagate inbound messages anymore. If the shutdown calls are propagated through the network somehow is specific to the protocol itself and so might differ.

Modifications:

- Add ChannelShutdownType and ChannelShutdownDirection
- Add ChannelOutboundInvoker.shutdown(ChannelShutdownType, ChannelPromise) method
- Add ChannelInboundInvoker.fireChannelShutdown(ChannelShutdownType) methods
- Add Channel.isShutdown(ChannelShutdownType) method
- Add ChannelHandler.shutdown(ChannelHandlerContext, ChannelShutdownType) and ChannelHandler.channelShutdown(ChannelHandlerContext, ChannelShutdownType) methods
- Refactor code to use the new methods and also add implementations for the different transports

Result:

Half-closure is now a core-concept of netty.
@normanmaurer
Fix epoll and io_uring half closure
1bb3947
@normanmaurer
Add comments
7444c49
@normanmaurer
normanmaurer force-pushed the shutdown_core branch from f5daeb5 to 7444c49 Compare December 9, 2025 19:18
@normanmaurer
Update state before notify promise to fix race
3a0dcaa
bryce-anderson
bryce-anderson reviewed Dec 10, 2025
View reviewed changes

@bryce-anderson bryce-anderson left a comment

Copy link
Copy Markdown
Contributor

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.

I looked at the interface changes and also think this makes a lot of sense.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@normanmaurer
normanmaurer merged commit 39f745e into 5.0 Dec 10, 2025
@normanmaurer
normanmaurer deleted the shutdown_core branch December 10, 2025 21:52
@normanmaurer normanmaurer mentioned this pull request Sep 22, 2026
suspend race fix #17588
Closed
@normanmaurer normanmaurer mentioned this pull request Oct 20, 2026
fix iouring zerocopy iov overwrite #17936
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bryce-anderson bryce-anderson bryce-anderson left review comments
@chrisvest chrisvest chrisvest approved these changes
@yawkat yawkat Awaiting requested review from yawkat

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

5.0.0.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@normanmaurer @chrisvest @bryce-anderson
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.