Skip to content
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: rework SharedFd #232

Merged

Conversation

FrankReh
Copy link
Collaborator

@FrankReh FrankReh commented Feb 8, 2023

This allows a 'file.close.wait' to return a true close return value. And it fixes the problem of indefinitely hanging when the SharedFd was still held by an in-flight operation.

It simplifies the low level close logic, using the async uring close operation when the caller is using file.close.wait but using the synchronous close mechanism provided by the std library when the SharedFd is allowed to go out of scope without having been closed first.

Manual closing of the file should be encouraged because it allows the user to see the return code.

In order to let the file owner call close and not hang when an in-flight was still in progress, this reworks the future to return when it sees the strong reference count drop to 1.

Fixes

This allows a 'file.close.wait' to return a true close return value.
And it fixes the problem of indefinitely hanging when the SharedFd was
still held by an in-flight operation.

It simplifies the low level close logic, using the async uring close
operation when the caller is using file.close.wait but using the
synchronous close mechanism provided by the std library when the SharedFd
is allowed to go out of scope without having been closed first.

Manual closing of the file should be encouraged because it allows the
user to see the return code.

In order to let the file owner call close and not hang when an in-flight
was still in progress, this reworks the future to return when it sees
the strong reference count drop to 1.
@FrankReh
Copy link
Collaborator Author

FrankReh commented Feb 8, 2023

I can add a test case that highlights the problem. I realized it doesn't require a large file being created. Even a small buffer is enough to trigger the Future being polled when that particular select! mechanism is used.

@FrankReh FrankReh requested a review from Noah-Kennedy February 8, 2023 18:29
@FrankReh FrankReh merged commit 96ad633 into tokio-rs:master Feb 10, 2023
@FrankReh FrankReh deleted the frankreh/fix-sharedfd-does-not-call-wake branch February 10, 2023 03:44
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.

2 participants