mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-02-17 05:15:14 +00:00
threadshare: Fix shutdown race condition
We might've already handled the shutdown unparking while doing the previous turn(s), so we have to check the atomic bool afterwards again and before waiting (potentially) forever. Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/issues/75
This commit is contained in:
parent
429e3027b3
commit
b84388b0f3
1 changed files with 8 additions and 0 deletions
|
@ -113,6 +113,7 @@ impl IOContextRunner {
|
|||
::tokio_timer::with_default(&timer_handle, &mut enter, |mut enter| {
|
||||
::tokio_reactor::with_default(&handle, &mut enter, |enter| loop {
|
||||
if self.shutdown.load(atomic::Ordering::SeqCst) > RUNNING {
|
||||
gst_debug!(CONTEXT_CAT, "Shutting down loop");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -167,6 +168,13 @@ impl IOContextRunner {
|
|||
{}
|
||||
gst_trace!(CONTEXT_CAT, "Turned current thread '{}'", self.name);
|
||||
|
||||
// We have to check again after turning in case we're supposed to shut down now
|
||||
// and already handled the unpark above
|
||||
if self.shutdown.load(atomic::Ordering::SeqCst) > RUNNING {
|
||||
gst_debug!(CONTEXT_CAT, "Shutting down loop");
|
||||
break;
|
||||
}
|
||||
|
||||
let elapsed = now.elapsed();
|
||||
gst_trace!(CONTEXT_CAT, "Elapsed {:?} after handling futures", elapsed);
|
||||
|
||||
|
|
Loading…
Reference in a new issue