forked from mirrors/gstreamer-rs
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
aa29567171
commit
217bbc3e94
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>> {
|
||||
let BusStream(ref bus, ref waker) = *self;
|
||||
|
||||
let mut waker = waker.lock().unwrap();
|
||||
let msg = bus.pop();
|
||||
if let Some(msg) = msg {
|
||||
Poll::Ready(Some(msg))
|
||||
} else {
|
||||
let mut waker = waker.lock().unwrap();
|
||||
*waker = Some(ctx.waker().clone());
|
||||
Poll::Pending
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue