mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 17:03:23 +00:00
committed by
Tate, Hongliang Tian
parent
985813c7f9
commit
c5009e38f1
@ -155,7 +155,7 @@ impl Producer<u8> {
|
||||
return_errno_with_message!(Errno::EPIPE, "the channel is shut down");
|
||||
}
|
||||
|
||||
let written_len = self.0.write(reader);
|
||||
let written_len = self.0.write(reader)?;
|
||||
self.update_pollee();
|
||||
|
||||
if written_len > 0 {
|
||||
@ -241,7 +241,7 @@ impl Consumer<u8> {
|
||||
// This must be recorded before the actual operation to avoid race conditions.
|
||||
let is_shutdown = self.is_shutdown();
|
||||
|
||||
let read_len = self.0.read(writer);
|
||||
let read_len = self.0.read(writer)?;
|
||||
self.update_pollee();
|
||||
|
||||
if read_len > 0 {
|
||||
@ -301,25 +301,13 @@ impl<R: TRights> Fifo<u8, R> {
|
||||
#[require(R > Read)]
|
||||
pub fn read(&self, writer: &mut dyn MultiWrite) -> Result<usize> {
|
||||
let mut rb = self.common.consumer.rb();
|
||||
match rb.read_fallible(writer) {
|
||||
Ok(len) => len,
|
||||
Err(e) => {
|
||||
error!("memory read failed on the ring buffer, error: {e:?}");
|
||||
0
|
||||
}
|
||||
}
|
||||
rb.read_fallible(writer)
|
||||
}
|
||||
|
||||
#[require(R > Write)]
|
||||
pub fn write(&self, reader: &mut dyn MultiRead) -> Result<usize> {
|
||||
let mut rb = self.common.producer.rb();
|
||||
match rb.write_fallible(reader) {
|
||||
Ok(len) => len,
|
||||
Err(e) => {
|
||||
error!("memory write failed on the ring buffer, error: {e:?}");
|
||||
0
|
||||
}
|
||||
}
|
||||
rb.write_fallible(reader)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user