mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-07 02:46:51 +00:00
crosvm: remove stdin from pollables at EOF/error
If reading from stdin returns EOF or an error, remove it from the list of pollables. BUG=none TEST=`vm_launcher start` and check that crosvm no longer pegs CPU Change-Id: I7971058701e6145884de9c52a8dd5b829373637b Reviewed-on: https://chromium-review.googlesource.com/745961 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
parent
ce374793bf
commit
082aecec87
1 changed files with 16 additions and 7 deletions
23
src/main.rs
23
src/main.rs
|
@ -713,13 +713,22 @@ fn run_control(mut vm: Vm,
|
||||||
}
|
}
|
||||||
STDIN => {
|
STDIN => {
|
||||||
let mut out = [0u8; 64];
|
let mut out = [0u8; 64];
|
||||||
let count = stdin_lock.read_raw(&mut out[..]).unwrap_or_default();
|
match stdin_lock.read_raw(&mut out[..]) {
|
||||||
if count != 0 {
|
Ok(0) => {
|
||||||
stdio_serial
|
// Zero-length read indicates EOF. Remove from pollables.
|
||||||
.lock()
|
pollables.retain(|&pollable| pollable.0 != STDIN);
|
||||||
.unwrap()
|
},
|
||||||
.queue_input_bytes(&out[..count])
|
Err(e) => {
|
||||||
.expect("failed to queue bytes into serial port");
|
warn!("error while reading stdin: {:?}", e);
|
||||||
|
pollables.retain(|&pollable| pollable.0 != STDIN);
|
||||||
|
},
|
||||||
|
Ok(count) => {
|
||||||
|
stdio_serial
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.queue_input_bytes(&out[..count])
|
||||||
|
.expect("failed to queue bytes into serial port");
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CHILD_SIGNAL => {
|
CHILD_SIGNAL => {
|
||||||
|
|
Loading…
Reference in a new issue