Skip to content

ensure the side which enbale SO_LINGER and call showdownOutput to start TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state #11982

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

Merged
merged 18 commits into from
Jan 11, 2022

Conversation

huibinliupush
Copy link
Contributor

@huibinliupush huibinliupush commented Jan 8, 2022

Motivation:

we can not call doDeregister to cancel the key of the channel from the selector in the io.netty.channel.AbstractChannel.AbstractUnsafe#shutdownOutput(io.netty.channel.ChannelPromise, java.lang.Throwable) method。

  • because we should ensure the side which enbale SO_LINGER and call showdownOutput to start TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state。

  • and the shutdown function does not block regardless of the SO_LINGER setting on the socket,so we don't need to use GlobalEventExecutor to execute the shutdown

Modification:

In summary there is no need to call prepareToClose() in the AbstractChannel.AbstractUnsafe#shutdownOutput method

Result:

Fixes issue #11981

client in the FIN_WAIT2 state can read and process these data which is sended by server in the CLOSE_WAIT state,when SO_LINGGER is used in the TCP half-closed scenario

…rt TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state。
…rt TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state。
@huibinliupush huibinliupush changed the title So linger halfclosure issue ensure the side which enbale SO_LINGER and call showdownOutput to start TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state Jan 8, 2022
Copy link
Member

@normanmaurer normanmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments :)

@normanmaurer normanmaurer added this to the 4.1.73.Final milestone Jan 10, 2022
@normanmaurer
Copy link
Member

@huibinliupush did you sigh our ICLA yet ?

@huibinliupush
Copy link
Contributor Author

huibinliupush commented Jan 10, 2022

@huibinliupush did you sigh our ICLA yet ?

@normanmaurer yeah I already signed it before
I will solve the problem of the unit test you commented tomorrow,because it's already midnight in china

huibinliupush and others added 4 commits January 10, 2022 22:42

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Norman Maurer <norman_maurer@apple.com>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Norman Maurer <norman_maurer@apple.com>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Norman Maurer <norman_maurer@apple.com>
- delete codec in the test channel pipeline

- use CountdownLatch to wait the halfClosure to finish

- call ReferenceCountUtil.release(msg) in the channelRead handler

- follow the same structure for tests, ensures the test will be run for NIO,OIO,Epoll and Kqueue
huibinliupush and others added 8 commits January 11, 2022 17:16

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…cketHalfClosedTest.java

Co-authored-by: Norman Maurer <norman_maurer@apple.com>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…cketHalfClosedTest.java

Co-authored-by: Norman Maurer <norman_maurer@apple.com>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…cketHalfClosedTest.java

Co-authored-by: Norman Maurer <norman_maurer@apple.com>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…cketHalfClosedTest.java

Co-authored-by: Norman Maurer <norman_maurer@apple.com>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…cketHalfClosedTest.java

Co-authored-by: Norman Maurer <norman_maurer@apple.com>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…cketHalfClosedTest.java

Co-authored-by: Norman Maurer <norman_maurer@apple.com>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
…cketHalfClosedTest.java

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
@normanmaurer
Copy link
Member

@huibinliupush please fix check style error:

Error:  /home/runner/work/netty/netty/transport/src/main/java/io/netty/channel/AbstractChannel.java:654: Line is longer than 120 characters (found 135). [LineLength]
901
Error:  /home/runner/work/netty/netty/transport/src/main/java/io/netty/channel/AbstractChannel.java:655: Line is longer than 120 characters (found 162). [LineLength]
902
Error:  /home/runner/work/netty/netty/transport/src/main/java/io/netty/channel/AbstractChannel.java:658: Line is longer than 120 characters (found 129). [LineLength]

@huibinliupush
Copy link
Contributor Author

@huibinliupush please fix check style error:

Error:  /home/runner/work/netty/netty/transport/src/main/java/io/netty/channel/AbstractChannel.java:654: Line is longer than 120 characters (found 135). [LineLength]
901
Error:  /home/runner/work/netty/netty/transport/src/main/java/io/netty/channel/AbstractChannel.java:655: Line is longer than 120 characters (found 162). [LineLength]
902
Error:  /home/runner/work/netty/netty/transport/src/main/java/io/netty/channel/AbstractChannel.java:658: Line is longer than 120 characters (found 129). [LineLength]

@normanmaurer fix it

@normanmaurer
Copy link
Member

@huibinliupush I think we are almost there..

Please also fix these:

Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:65: two or more consecutive empty lines [RegexpMultiline]
5205
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:69: Line is longer than 120 characters (found 128). [LineLength]
5206
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:87:80: '{' is not preceded with whitespace. [WhitespaceAround]
5207
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:91:71: 'typecast' is not followed by whitespace. [WhitespaceAfter]
5208
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:101: an empty line before } [RegexpMultiline]
5209
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:102: two or more consecutive empty lines [RegexpMultiline]
5210
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:110:79: '{' is not preceded with whitespace. [WhitespaceAround]

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@huibinliupush
Copy link
Contributor Author

@huibinliupush I think we are almost there..

Please also fix these:

Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:65: two or more consecutive empty lines [RegexpMultiline]
5205
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:69: Line is longer than 120 characters (found 128). [LineLength]
5206
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:87:80: '{' is not preceded with whitespace. [WhitespaceAround]
5207
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:91:71: 'typecast' is not followed by whitespace. [WhitespaceAfter]
5208
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:101: an empty line before } [RegexpMultiline]
5209
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:102: two or more consecutive empty lines [RegexpMultiline]
5210
Error:  /home/runner/work/netty/netty/testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java:110:79: '{' is not preceded with whitespace. [WhitespaceAround]

@normanmaurer my intellij checksytle plugin reported error but did not prompt specific error information, so it took me some time,sorry about that

@normanmaurer normanmaurer merged commit d60ea59 into netty:4.1 Jan 11, 2022
@normanmaurer
Copy link
Member

@huibinliupush thanks a lot !

normanmaurer added a commit that referenced this pull request Jan 11, 2022
…rt TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state (#11982)

Motivation:

we can not call `doDeregister` to cancel the key of the channel from the selector in the `io.netty.channel.AbstractChannel.AbstractUnsafe#shutdownOutput(io.netty.channel.ChannelPromise, java.lang.Throwable)` method。

- because we should ensure the side which enbale `SO_LINGER` and call `showdownOutput` to start TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state。

- and the shutdown function does not block regardless of the SO_LINGER setting on the socket,so we don't need to use GlobalEventExecutor to execute the shutdown

Modification:

In summary there is no need to call `prepareToClose()` in the `AbstractChannel.AbstractUnsafe#shutdownOutput` method

Result:

Fixes issue #11981

client in the FIN_WAIT2 state can read and process these data which is sended by server in the CLOSE_WAIT state,when SO_LINGGER is used in the TCP half-closed scenario

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
@huibinliupush
Copy link
Contributor Author

@huibinliupush thanks a lot !

@normanmaurer so grateful to have learned so much from you,also thank you very much for reviewing this PR

@huibinliupush huibinliupush deleted the so_linger-halfclosure-issue branch January 11, 2022 23:52
10brothers pushed a commit to 10brothers/netty that referenced this pull request Jan 20, 2022
…rt TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state (netty#11982)

Motivation:

we can not call `doDeregister` to cancel the key of the channel from the selector in the `io.netty.channel.AbstractChannel.AbstractUnsafe#shutdownOutput(io.netty.channel.ChannelPromise, java.lang.Throwable)` method。

- because we should ensure the side which enbale `SO_LINGER` and call `showdownOutput` to start TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state。

- and the shutdown function does not block regardless of the SO_LINGER setting on the socket,so we don't need to use GlobalEventExecutor to execute the shutdown

Modification:

In summary there is no need to call `prepareToClose()` in the `AbstractChannel.AbstractUnsafe#shutdownOutput` method

Result:

Fixes issue netty#11981 

client in the FIN_WAIT2 state can read and process these data which is sended by server in the CLOSE_WAIT state,when SO_LINGGER is used in the TCP half-closed scenario

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
…rt TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state (netty#11982)

Motivation:

we can not call `doDeregister` to cancel the key of the channel from the selector in the `io.netty.channel.AbstractChannel.AbstractUnsafe#shutdownOutput(io.netty.channel.ChannelPromise, java.lang.Throwable)` method。

- because we should ensure the side which enbale `SO_LINGER` and call `showdownOutput` to start TCP half-closure in fin_wait2 state can still receive and process the data which is send by another side in the close_wait state。

- and the shutdown function does not block regardless of the SO_LINGER setting on the socket,so we don't need to use GlobalEventExecutor to execute the shutdown

Modification:

In summary there is no need to call `prepareToClose()` in the `AbstractChannel.AbstractUnsafe#shutdownOutput` method

Result:

Fixes issue netty#11981 

client in the FIN_WAIT2 state can read and process these data which is sended by server in the CLOSE_WAIT state,when SO_LINGGER is used in the TCP half-closed scenario

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
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.

None yet

2 participants