mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
base: Remove is_packet_ready
BUG=b:184398671 TEST=cargo test Change-Id: I91770504ef95121246e75e29e9fd64fc32022fc2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3002387 Auto-Submit: Vikram Auradkar <auradkar@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Vikram Auradkar <auradkar@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
fa32ced1e0
commit
ede68c76ba
2 changed files with 11 additions and 26 deletions
|
@ -104,13 +104,6 @@ impl Tube {
|
|||
.map_err(Error::Json)
|
||||
}
|
||||
|
||||
/// Returns true if there is a packet ready to `recv` without blocking.
|
||||
///
|
||||
/// If there is an error trying to determine if there is a packet ready, this returns false.
|
||||
pub fn is_packet_ready(&self) -> bool {
|
||||
self.socket.get_readable_bytes().unwrap_or(0) > 0
|
||||
}
|
||||
|
||||
pub fn set_send_timeout(&self, timeout: Option<Duration>) -> Result<()> {
|
||||
self.socket
|
||||
.set_write_timeout(timeout)
|
||||
|
|
22
src/linux.rs
22
src/linux.rs
|
@ -3083,27 +3083,19 @@ fn run_control<V: VmArch + 'static, Vcpu: VcpuArch + 'static>(
|
|||
}
|
||||
}
|
||||
|
||||
for event in events.iter().filter(|e| e.is_hungup) {
|
||||
match event.token {
|
||||
Token::Exit => {}
|
||||
Token::Suspend => {}
|
||||
Token::ChildSignal => {}
|
||||
Token::IrqFd { index: _ } => {}
|
||||
Token::VmControlServer => {}
|
||||
Token::VmControl { index } => {
|
||||
// It's possible more data is readable and buffered while the socket is hungup,
|
||||
// so don't delete the tube from the poll context until we're sure all the
|
||||
// data is read.
|
||||
if control_tubes
|
||||
.get(index)
|
||||
.map(|s| !s.as_ref().is_packet_ready())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
// Below case covers a condition where we have received a hungup event and the tube is not
|
||||
// readable.
|
||||
// In case of readable tube, once all data is read, any attempt to read more data on hungup
|
||||
// tube should fail. On such failure, we get Disconnected error and index gets added to
|
||||
// vm_control_indices_to_remove by the time we reach here.
|
||||
for event in events.iter().filter(|e| e.is_hungup && !e.is_readable) {
|
||||
if let Token::VmControl { index } = event.token {
|
||||
vm_control_indices_to_remove.push(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort in reverse so the highest indexes are removed first. This removal algorithm
|
||||
// preserves correct indexes as each element is removed.
|
||||
|
|
Loading…
Reference in a new issue