gst-plugins-rs/generic/threadshare
François Laignel a45f944edd ts/async_wrapper: remove fd from reactor before dropping its handle
The I/O handle was dropped prior to removing it from the reactor,
which caused `Poller::delete` to fail due to an invalid file
descriptor. This used to happen silently unless the same fd was
added again, e.g. by changing states in the pipeline as follow:

    Null -> Playing -> Null -> Playing.

In which case `Poller::add` failed due to an already existing file.

This commit makes sure the fd is removed from the reactor prior to
dropping the handle. In order to achieve this, a new task is spawned
on the `Context` on which the I/O was originally registered, allowing
it to access the proper `Reactor`. The I/O can then safely be dropped.

Because the I/O handle is moved to the spawned future, this solution
requires adding the `Send + 'static` bounds to the I/O handle used
within the `Async` wrapper. This appears not too restrictive for
existing implementations though. Other attempts were considered,
but they would cause deadlocks.

This new approach also solves a potential race condition where a
fd could be re-registered in a `Reactor` before it was removed.
2022-06-30 11:13:39 +00:00
..
examples ts/examples: add rtp mode with jitter-buffer & trace stop duration 2022-03-28 08:47:32 +00:00
src ts/async_wrapper: remove fd from reactor before dropping its handle 2022-06-30 11:13:39 +00:00
tests ts: add test pipeline::socket_play_null_play 2022-06-30 11:13:39 +00:00
build.rs fix-getters-calls 0.3.0 pass 2021-04-20 18:19:58 +02:00
Cargo.toml ts/async_wrapper: remove fd from reactor before dropping its handle 2022-06-30 11:13:39 +00:00
LICENSE-LGPLv2 Add LICENSE files to each individual crate 2020-07-10 13:06:28 +03:00