async: Close listener fd after server shutdown#200
Merged
lifupan merged 1 commit intocontainerd:masterfrom Jul 6, 2023
Merged
Conversation
The listener fd is not closed when server.shutdown(), this will make a residual fd if a process start and close different servers for many times. Signed-off-by: Abel Feng <fshb1988@gmail.com>
a9a1cca to
cc6b187
Compare
Member
|
@abel-von Good catch, this bug is caused by ttrpc-rust/src/asynchronous/server.rs Line 216 in b13d3fd Would you mind back porting this to 0.5.0, 0.6.0 and 0.7.0? if you are too busy to do it, never mind, I will do it. Thanks a million. |
Tim-Zhang
approved these changes
Jul 4, 2023
Contributor
Author
|
@Tim-Zhang The CI seems to have some wired error, could you help solving it please? I can cherry-pick this to other branches, shall I submit the PR too? |
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## master #200 +/- ##
==========================================
- Coverage 24.47% 24.42% -0.05%
==========================================
Files 17 17
Lines 2521 2526 +5
==========================================
Hits 617 617
- Misses 1904 1909 +5
☔ View full report in Codecov by Sentry. |
Member
It works now. |
lifupan
approved these changes
Jul 6, 2023
Tim-Zhang
added a commit
to Tim-Zhang/ttrpc-rust
that referenced
this pull request
Aug 22, 2023
Cut the release for containerd#196, containerd#197, containerd#200, containerd#203, containerd#208 Signed-off-by: Tim Zhang <tim@hyper.sh>
Merged
KarstenB
pushed a commit
to KarstenB/ttrpc-rust
that referenced
this pull request
May 1, 2025
async: Close listener fd after server shutdown
KarstenB
pushed a commit
to KarstenB/ttrpc-rust
that referenced
this pull request
May 1, 2025
Cut the release for containerd#196, containerd#197, containerd#200, containerd#203, containerd#208 Signed-off-by: Tim Zhang <tim@hyper.sh>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
the listener fd is not closed after the server shutdown, this will make a residual socket fd in the process if it is running different servers again and again.
here I changed the example codes to reproduce it:
if I kill -SIGHUP of this process, we can see that the fd count is increasing:

this PR fix the issue by close the listener fd. this is ok for those calling server.bind() with the socket address, but if the listener is opened from outside, and the lifecycle is managed outside, then it may cause the twice close error. but we can see that the listener is closed in the sync codes. so I think we can assume that the server has taken the ownership of listener fd after it is added into the server.