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(()),
token => loop {
match clients.get(token.0).unwrap().as_ref().unwrap().dispatch() {
Ok(_) => continue,
Err(e) => match e.kind() {
std::io::ErrorKind::WouldBlock => break,
_ => {
clients.remove(token.0);
break;
token => {
let client =
clients.get(token.0).and_then(|client| client.as_ref());
if let Some(client) = client {
loop {
match client.dispatch() {
Ok(_) => continue,
Err(e) => match e.kind() {
std::io::ErrorKind::WouldBlock => break,
_ => {
clients.remove(token.0);
break;
}
},
}
},
}
}
},
}
}
}
}