From b0837733a9ffcaa5f267bbaf68e82b5aca7496d5 Mon Sep 17 00:00:00 2001 From: deathwish5 Date: Sat, 2 May 2020 19:01:02 +0800 Subject: [PATCH] fix fifo-test --- zircon-object/src/ipc/fifo.rs | 9 ++++++--- zircon-syscall/src/object.rs | 18 +++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/zircon-object/src/ipc/fifo.rs b/zircon-object/src/ipc/fifo.rs index d1e823c4d..6451d7403 100644 --- a/zircon-object/src/ipc/fifo.rs +++ b/zircon-object/src/ipc/fifo.rs @@ -104,14 +104,17 @@ impl Fifo { let count_size = count * elem_size; assert_eq!(data.len(), count_size); - let peer = self.peer.upgrade().ok_or(ZxError::PEER_CLOSED)?; + let peer = self.peer.upgrade(); let mut recv_queue = self.recv_queue.lock(); if recv_queue.is_empty() { + if peer.is_none() { + return Err(ZxError::PEER_CLOSED); + } return Err(ZxError::SHOULD_WAIT); } let read_size = count_size.min(recv_queue.len()); - if recv_queue.len() == self.capacity() { - peer.base.signal_set(Signal::WRITABLE); + if recv_queue.len() == self.capacity() && peer.is_some() { + peer.unwrap().base.signal_set(Signal::WRITABLE); } for (i, x) in recv_queue.drain(..read_size).enumerate() { data[i] = x; diff --git a/zircon-syscall/src/object.rs b/zircon-syscall/src/object.rs index acd4be543..fe3bb07ac 100644 --- a/zircon-syscall/src/object.rs +++ b/zircon-syscall/src/object.rs @@ -138,13 +138,17 @@ impl Syscall<'_> { "object.wait_one: handle={:#x?}, signals={:#x?}, deadline={:#x?}, observed={:#x?}", handle, signals, deadline, observed ); - let signals = Signal::from_bits(signals).ok_or_else(|| { - if !deadline.is_positive() { - ZxError::TIMED_OUT - } else { - ZxError::INVALID_ARGS - } - })?; + let signals = match signals{ + 0xFFFFFFFF => Signal::all(), + _ => + Signal::from_bits(signals).ok_or_else(|| { + if !deadline.is_positive() { + ZxError::TIMED_OUT + } else { + ZxError::INVALID_ARGS + } + })?, + }; let proc = self.thread.proc(); let object = proc.get_dyn_object_with_rights(handle, Rights::WAIT)?; let cancel_token = proc.get_cancel_token(handle)?;