mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-01-25 00:18:26 +00:00
bus: Take the mutex before popping messages for the bus stream
Otherwise a message might arrive between popping, getting None and locking the mutex for storing the waker. In that case we would never be woken up.
This commit is contained in:
parent
db1c341cdf
commit
b127f93cb9
1 changed files with 1 additions and 1 deletions
|
@ -269,11 +269,11 @@ impl Stream for BusStream {
|
||||||
fn poll_next(self: Pin<&mut Self>, ctx: &mut Context) -> Poll<Option<Self::Item>> {
|
fn poll_next(self: Pin<&mut Self>, ctx: &mut Context) -> Poll<Option<Self::Item>> {
|
||||||
let BusStream(ref bus, ref waker) = *self;
|
let BusStream(ref bus, ref waker) = *self;
|
||||||
|
|
||||||
|
let mut waker = waker.lock().unwrap();
|
||||||
let msg = bus.pop();
|
let msg = bus.pop();
|
||||||
if let Some(msg) = msg {
|
if let Some(msg) = msg {
|
||||||
Poll::Ready(Some(msg))
|
Poll::Ready(Some(msg))
|
||||||
} else {
|
} else {
|
||||||
let mut waker = waker.lock().unwrap();
|
|
||||||
*waker = Some(ctx.waker().clone());
|
*waker = Some(ctx.waker().clone());
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue