Merge branch 'xMAC94x/remove_busy_waiting' into 'master'

detect EOL on stdin and no longer try to read commands.

See merge request veloren/veloren!1369
This commit is contained in:
Marcel 2020-09-07 15:04:05 +00:00
commit 4bd41ddd9c
2 changed files with 19 additions and 8 deletions

View File

@ -119,10 +119,7 @@ fn main() -> io::Result<()> {
break;
},
},
Err(e) => match e {
mpsc::TryRecvError::Empty => {},
mpsc::TryRecvError::Disconnected => panic!(),
},
Err(mpsc::TryRecvError::Empty) | Err(mpsc::TryRecvError::Disconnected) => {},
};
// Wait for the next tick.

View File

@ -118,10 +118,24 @@ impl Tui {
while running.load(Ordering::Relaxed) {
let mut line = String::new();
io::stdin().read_line(&mut line).unwrap();
match io::stdin().read_line(&mut line) {
Err(e) => {
error!(
?e,
"couldn't read from stdin, cli commands are disabled now!"
);
break;
},
Ok(0) => {
//Docker seem to send EOL all the time
warn!("EOL recieved, cli commands are disabled now!");
break;
},
Ok(_) => {
debug!(?line, "basic mode: command entered");
parse_command(&line, &mut msg_s);
},
}
}
});
} else {