Re: [PATCH 7/7] rust: file: add abstraction for `poll_table`

From: Alice Ryhl
Date: Fri Dec 01 2023 - 06:48:00 EST


Benno Lossin <benno.lossin@xxxxxxxxx> writes:
>> +#[pinned_drop]
>> +impl PinnedDrop for PollCondVar {
>> + fn drop(self: Pin<&mut Self>) {
>> + // Clear anything registered using `register_wait`.
>> + self.inner.notify(1, bindings::POLLHUP | bindings::POLLFREE);
>
> Isn't notifying only a single thread problematic, since a user could
> misuse the `PollCondVar` (since all functions of `CondVar` are also
> accessible) and also `.wait()` on the condvar? When dropping a
> `PollCondVar` it might notify only the user `.wait()`, but not the
> `PollTable`. Or am I missing something?

Using POLLFREE clears everything. However, this should probably be updated to
use `wake_up_pollfree` instead.

Note that calls to `.wait()` are definitely gone by the time the destructor
runs, since such calls borrows the `PollCondVar`, preventing you from running
the destructor.

Alice