Re: [RFC PATCH v1 5/5] rust: file: add `DeferredFdCloser`

From: Martin Rodriguez Reboredo
Date: Wed Aug 09 2023 - 00:35:10 EST


On 7/20/23 12:28, Alice Ryhl wrote:
This adds a new type called `DeferredFdCloser` that can be used to close
files by their fd in a way that is safe even if the file is currently
held using `fdget`.

This is done by grabbing an extra refcount to the file and dropping it
in a task work once we return to userspace.

See comments on `binder_do_fd_close` and commit `80cd795630d65` for
motivation.

Please provide links, at least for the doc comment.


Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
---
[...]
+/// Helper used for closing file descriptors in a way that is safe even if the file is currently
+/// held using `fdget`.
+///
+/// See comments on `binder_do_fd_close` and commit `80cd795630d65`.

Ditto.

+pub struct DeferredFdCloser {
+ inner: Box<DeferredFdCloserInner>,
+}
+
[...]