-
Notifications
You must be signed in to change notification settings - Fork 47
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
Fix bug: Async client may not close #236
base: master
Are you sure you want to change the base?
Conversation
when just new a Client,the fd will increase.
@@ -45,6 +46,7 @@ impl Client { | |||
pub fn new(fd: RawFd) -> Client { | |||
let stream = utils::new_unix_stream_from_raw_fd(fd); |
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.
The fd will be closed when ClientClose dropping
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.
hi, It looks like async client didn't hold ClientClose? If I miss?
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.
The Connection
holds the fd. Did not the fd close when conn was dropped?
let conn = Connection::new(stream, delegate);
tokio::spawn(async move { conn.run().await });
I think connection is client's member, the lifetime of connection should not above the client struct, if client is drop as well as conn should exit. If conn is lock may cause thread leak. |
I am not sure, is not the fd closed by the Connection. If true, there is now a risk of a double close. |
I check the connection , but there's no fd release, please check it again if i missed. |
Raw fd looks like difficulty to manage ownership and lifecycle how about use this https://docs.rs/tokio/latest/tokio/net/struct.UnixStream.html. If it is reasonable , I'd like to change it . @wllenyj @Tim-Zhang OwnedFd may be greater than Rawfd |
when just new a Client,the fd will increase.
I also think the lifetime in async client is too long. also in sync #225 .
I obtained the following test code for this phenomenon: