mirror of https://github.com/ctz/rustls
examples: ignore interrupted syscalls for mio poll
While in general these examples shouldn't be written to handle errors, the long-running MIO poll operation is especially prone to returning interrupted syscall errors when a debugger is attached. This commit updates each MIO example to ignore this class of error rather than panicing, improving the debugging experience.
This commit is contained in:
parent
deffd3fa55
commit
1cdb10f8b4
|
@ -534,7 +534,14 @@ fn main() {
|
|||
tlsclient.register(poll.registry());
|
||||
|
||||
loop {
|
||||
poll.poll(&mut events, None).unwrap();
|
||||
match poll.poll(&mut events, None) {
|
||||
Ok(_) => {}
|
||||
// Polling can be interrupted (e.g. by a debugger) - retry if so.
|
||||
Err(e) if e.kind() == io::ErrorKind::Interrupted => continue,
|
||||
Err(e) => {
|
||||
panic!("poll failed: {:?}", e)
|
||||
}
|
||||
}
|
||||
|
||||
for ev in events.iter() {
|
||||
tlsclient.ready(ev);
|
||||
|
|
|
@ -702,7 +702,14 @@ fn main() {
|
|||
|
||||
let mut events = mio::Events::with_capacity(256);
|
||||
loop {
|
||||
poll.poll(&mut events, None).unwrap();
|
||||
match poll.poll(&mut events, None) {
|
||||
Ok(_) => {}
|
||||
// Polling can be interrupted (e.g. by a debugger) - retry if so.
|
||||
Err(e) if e.kind() == io::ErrorKind::Interrupted => continue,
|
||||
Err(e) => {
|
||||
panic!("poll failed: {:?}", e)
|
||||
}
|
||||
}
|
||||
|
||||
for event in events.iter() {
|
||||
match event.token() {
|
||||
|
|
Loading…
Reference in New Issue