-
Notifications
You must be signed in to change notification settings - Fork 2
Fix:iperf Follow-up Robustness And PR CI #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -276,18 +276,23 @@ impl PipeFile { | |
| buffer.set_capacity(new_size)?; | ||
| Ok(buffer.get_capacity()) | ||
| } | ||
|
|
||
| pub fn read_ready(&self) -> bool { | ||
| self.end_type.readable() && self.buffer.lock().can_read_now() | ||
| } | ||
|
|
||
| pub fn write_ready(&self) -> bool { | ||
| self.end_type.writable() && self.buffer.lock().can_write_now() | ||
| } | ||
|
Comment on lines
+284
to
+286
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the read end of a pipe is closed, any subsequent write to the pipe will fail immediately with Currently, We should update pub fn write_ready(&self) -> bool {
if !self.end_type.writable() {
return false;
}
let buf = self.buffer.lock();
buf.can_write_now() || (buf.ever_had_reader && buf.read_end_count == 0)
} |
||
| } | ||
|
|
||
| impl File for PipeFile { | ||
| fn readable(&self) -> bool { | ||
| self.end_type.readable() && self.buffer.lock().can_read_now() | ||
| self.end_type.readable() | ||
| } | ||
|
|
||
| fn writable(&self) -> bool { | ||
| if !self.end_type.writable() { | ||
| return false; | ||
| } | ||
| self.buffer.lock().can_write_now() | ||
| self.end_type.writable() | ||
| } | ||
|
|
||
| fn read(&self, buf: &mut [u8]) -> Result<usize, FsError> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The helper functions
file_read_readyandfile_write_readycurrently take&Arc<dyn File>as their parameter. However, they only need to perform operations on the underlyingdyn Filetrait object (viaas_any()andreadable()/writable()).By changing the parameter type to
&dyn File, we decouple these helper functions from theArcsmart pointer, making them more idiomatic, flexible, and reusable. Deref coercion will automatically handle passing&Arc<dyn File>at the call sites without requiring any modifications there.