GeezerVison is showing github.com — Add comments · netty/netty@341d4e7
File treeExpand file treeCollapse file tree Open diff view settings codec-classes-quic/src/main/java/io/netty/handler/codec/quic codec-http2/src/main/java/io/netty/handler/codec/http2 codec-http3/src/main/java/io/netty/handler/codec/http3 testsuite/src/main/java/io/netty/testsuite/transport/socket transport/src/main/java/io/netty/channel
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicheQuicStreamChannel.java +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -398,6 +398,10 @@ public void shutdown(ChannelShutdownType type, ChannelPromise promise) { | 398 | 398 | } | 399 | 399 |
| 400 | 400 | if (write) { | | 401 | + if (outputShutdown) { | | 402 | + promise.setSuccess(); | | 403 | + return; | | 404 | + } | 401 | 405 | ioTransport.writeWithoutCheckChannelState(QuicStreamFrame.EMPTY_FIN, newPromise() | 402 | 406 | .addListener(f -> { | 403 | 407 | if (f.isSuccess()) { | @@ -412,6 +416,10 @@ public void shutdown(ChannelShutdownType type, ChannelPromise promise) { | 412 | 416 | })); | 413 | 417 | ioTransport.flush(); | 414 | 418 | } else { | | 419 | + if (inputShutdown) { | | 420 | + promise.setSuccess(); | | 421 | + return; | | 422 | + } | 415 | 423 | int error; | 416 | 424 | if (type.data() == null) { | 417 | 425 | error = 0; | |
Collapse file Copy file name to clipboardExpand all lines: codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -71,10 +71,10 @@ public boolean visit(Http2FrameStream stream) { | 71 | 71 | }; | 72 | 72 |
| 73 | 73 | static final Http2FrameStreamVisitor CHANNEL_INPUT_SHUTDOWN_READ_COMPLETE_VISITOR = | 74 | | - new UserEventStreamVisitor(ChannelShutdownType.newInbound()); | | 74 | + new ShutdownEventVisitor(ChannelShutdownType.newInbound()); | 75 | 75 |
| 76 | 76 | static final Http2FrameStreamVisitor CHANNEL_OUTPUT_SHUTDOWN_EVENT_VISITOR = | 77 | | - new UserEventStreamVisitor(ChannelShutdownType.newOutbound()); | | 77 | + new ShutdownEventVisitor(ChannelShutdownType.newOutbound()); | 78 | 78 |
| 79 | 79 | static final Http2FrameStreamVisitor SSL_CLOSE_COMPLETION_EVENT_VISITOR = new Http2FrameStreamVisitor() { | 80 | 80 | @Override | @@ -97,11 +97,11 @@ public boolean visit(Http2FrameStream stream) { | 97 | 97 | /** | 98 | 98 | * {@link Http2FrameStreamVisitor} that fires the user event for every active stream pipeline. | 99 | 99 | */ | 100 | | - private static final class UserEventStreamVisitor implements Http2FrameStreamVisitor { | | 100 | + private static final class ShutdownEventVisitor implements Http2FrameStreamVisitor { | 101 | 101 |
| 102 | 102 | private final ChannelShutdownType type; | 103 | 103 |
| 104 | | - UserEventStreamVisitor(ChannelShutdownType type) { | | 104 | + ShutdownEventVisitor(ChannelShutdownType type) { | 105 | 105 | this.type = checkNotNull(type, "type"); | 106 | 106 | } | 107 | 107 |
| |
Collapse file Copy file name to clipboardExpand all lines: codec-http3/src/main/java/io/netty/handler/codec/http3/Http3ControlStreamInboundHandler.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -247,7 +247,7 @@ public final void channelActive(ChannelHandlerContext ctx) { | 247 | 247 |
| 248 | 248 | @Override | 249 | 249 | public void channelShutdown(ChannelHandlerContext ctx, ChannelShutdownType type) { | 250 | | - //streamClosed(ctx); | | 250 | + streamClosed(ctx); | 251 | 251 | if (type.direction() == ChannelShutdownDirection.Inbound) { | 252 | 252 | // See https://quicwg.org/base-drafts/draft-ietf-quic-qpack.html#section-4.2 | 253 | 253 | criticalStreamClosed(ctx); | |
Collapse file Copy file name to clipboardExpand all lines: codec-http3/src/main/java/io/netty/handler/codec/http3/Http3RequestStreamInboundHandler.java +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,6 +51,7 @@ public void channelShutdown(ChannelHandlerContext ctx, ChannelShutdownType type) | 51 | 51 | if (type.direction() == ChannelShutdownDirection.Inbound) { | 52 | 52 | channelInputClosed(ctx); | 53 | 53 | } | | 54 | + ctx.fireChannelShutdown(type); | 54 | 55 | } | 55 | 56 |
| 56 | 57 | @Override | |
Collapse file Copy file name to clipboardExpand all lines: testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java +3-22Lines changed: 3 additions & 22 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -228,25 +228,10 @@ public void run(Bootstrap bootstrap) throws Throwable { | 228 | 228 | } | 229 | 229 |
| 230 | 230 | public void testShutdownOutputSoLingerNoAssertError(Bootstrap cb) throws Throwable { | 231 | | - testShutdownSoLingerNoAssertError0(cb, true); | | 231 | + testShutdownSoLingerNoAssertError0(cb); | 232 | 232 | } | 233 | 233 |
| 234 | | - @Test | 235 | | - @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS) | 236 | | - public void testShutdownSoLingerNoAssertError(TestInfo testInfo) throws Throwable { | 237 | | - run(testInfo, new Runner<Bootstrap>() { | 238 | | - @Override | 239 | | - public void run(Bootstrap bootstrap) throws Throwable { | 240 | | - testShutdownSoLingerNoAssertError(bootstrap); | 241 | | - } | 242 | | - }); | 243 | | - } | 244 | | - | 245 | | - public void testShutdownSoLingerNoAssertError(Bootstrap cb) throws Throwable { | 246 | | - testShutdownSoLingerNoAssertError0(cb, false); | 247 | | - } | 248 | | - | 249 | | - private void testShutdownSoLingerNoAssertError0(Bootstrap cb, boolean output) throws Throwable { | | 234 | + private void testShutdownSoLingerNoAssertError0(Bootstrap cb) throws Throwable { | 250 | 235 | ServerSocket ss = new ServerSocket(); | 251 | 236 | Socket s = null; | 252 | 237 |
| @@ -259,11 +244,7 @@ private void testShutdownSoLingerNoAssertError0(Bootstrap cb, boolean output) th | 259 | 244 |
| 260 | 245 | cf.sync(); | 261 | 246 |
| 262 | | - if (output) { | 263 | | - cf.channel().shutdown(ChannelShutdownType.newOutbound()).sync(); | 264 | | - } else { | 265 | | - cf.channel().shutdown(ChannelShutdownType.newOutbound()).sync(); | 266 | | - } | | 247 | + cf.channel().shutdown(ChannelShutdownType.newOutbound()).sync(); | 267 | 248 | } finally { | 268 | 249 | if (s != null) { | 269 | 250 | s.close(); | |
Collapse file Copy file name to clipboardExpand all lines: transport/src/main/java/io/netty/channel/AbstractChannel.java -9Lines changed: 0 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -399,7 +399,6 @@ public void shutdown(ChannelShutdownType type, ChannelPromise promise) { | 399 | 399 | } | 400 | 400 | safeCascade(f, promise); | 401 | 401 | if (f.isSuccess() && type.direction() == ChannelShutdownDirection.Outbound) { | 402 | | - // TODO: IS this correct ? | 403 | 402 | pipeline().fireChannelShutdown(ChannelShutdownType.newOutbound()); | 404 | 403 | } | 405 | 404 | })); | @@ -751,13 +750,6 @@ public void run() { | 751 | 750 | public void read() { | 752 | 751 | assertEventLoop(); | 753 | 752 |
| 754 | | - /* | 755 | | - if (isShutdown(ChannelShutdownDirection.Inbound)) { | 756 | | - // Input was shutdown so not try to read. | 757 | | - return; | 758 | | - } | 759 | | - */ | 760 | | - | 761 | 753 | try { | 762 | 754 | doBeginRead(); | 763 | 755 | } catch (final Exception e) { | @@ -984,7 +976,6 @@ private void shutdownOutput(final ChannelPromise promise, Throwable cause) { | 984 | 976 |
| 985 | 977 | ioTransport.safeCascade(f, promise); | 986 | 978 | outboundBuffer.failFlushedAndClose(shutdownCause, false, shutdownCause, true); | 987 | | - // TODO: Is this correct ? | 988 | 979 | pipeline().fireChannelShutdown(ChannelShutdownType.newOutbound()); | 989 | 980 | }); | 990 | 981 | doShutdown(ChannelShutdownType.newOutbound(), shutdownPromise); | |
Collapse file Copy file name to clipboardExpand all lines: transport/src/main/java/io/netty/channel/ChannelOutboundHandler.java +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -100,6 +100,7 @@ void connect( | 100 | 100 | * @throws Exception thrown if an error occurs | 101 | 101 | */ | 102 | 102 | void flush(ChannelHandlerContext ctx); | | 103 | + | 103 | 104 | /** | 104 | 105 | * Called once a shutdown operation was requested and should be executed. | 105 | 106 | * | |
Collapse file Copy file name to clipboardExpand all lines: transport/src/main/java/io/netty/channel/DefaultChannelPipeline.java +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1206,9 +1206,8 @@ protected void onUnhandledInboundUserEventTriggered(Object evt) { | 1206 | 1206 | } | 1207 | 1207 |
| 1208 | 1208 | /** | 1209 | | - * Called once an user event hit the end of the {@link ChannelPipeline} without been handled by the user | | 1209 | + * Called once a shutdown event hit the end of the {@link ChannelPipeline} without been handled by the user | 1210 | 1210 | * in {@link ChannelInboundHandler#channelShutdown(ChannelHandlerContext, ChannelShutdownType)}. | 1211 | | - * This method is responsible to call {@link ReferenceCountUtil#release(Object)} on the given event at some point. | 1212 | 1211 | */ | 1213 | 1212 | protected void onUnhandledInboundChannelShutdown(ChannelShutdownType type) { | 1214 | 1213 | } | |
|