fix(event loop): don't try to get client every time in loop

This commit is contained in:
Nova
2022-07-12 09:08:27 -04:00
parent 39ce8214b4
commit 159afc007c

View File

@@ -61,18 +61,24 @@ impl EventLoop {
} }
}, },
STOP => return Ok(()), STOP => return Ok(()),
token => loop { token => {
match clients.get(token.0).unwrap().as_ref().unwrap().dispatch() { let client =
Ok(_) => continue, clients.get(token.0).and_then(|client| client.as_ref());
Err(e) => match e.kind() { if let Some(client) = client {
std::io::ErrorKind::WouldBlock => break, loop {
_ => { match client.dispatch() {
clients.remove(token.0); Ok(_) => continue,
break; Err(e) => match e.kind() {
std::io::ErrorKind::WouldBlock => break,
_ => {
clients.remove(token.0);
break;
}
},
} }
}, }
} }
}, }
} }
} }
} }