diff --git a/TODO.md b/TODO.md index 396e439..932b5b2 100644 --- a/TODO.md +++ b/TODO.md @@ -9,8 +9,6 @@ * is it even necessary to check if event is readable in poll, since that is all we're listening for? * privdrop -* on error because connection is closed, don't handle the same as for io - errors etc ## aquatic_udp * mio: set oneshot for epoll and kqueue? otherwise, stop reregistering? diff --git a/aquatic_ws/src/lib/network/mod.rs b/aquatic_ws/src/lib/network/mod.rs index 31a21d6..ec003e5 100644 --- a/aquatic_ws/src/lib/network/mod.rs +++ b/aquatic_ws/src/lib/network/mod.rs @@ -182,7 +182,12 @@ pub fn run_handshakes_and_read_messages( }, Err(Io(err)) if err.kind() == ErrorKind::WouldBlock => { break; - } + }, + Err(tungstenite::Error::ConnectionClosed) => { + remove_connection_if_exists(connections, poll_token); + + break + }, Err(err) => { eprintln!("error reading messages: {}", err); @@ -229,8 +234,9 @@ pub fn send_out_messages( match established_ws.ws.write_message(out_message.to_ws_message()){ Ok(()) => {}, - Err(Io(err)) if err.kind() == ErrorKind::WouldBlock => { - continue; + Err(Io(err)) if err.kind() == ErrorKind::WouldBlock => {}, + Err(tungstenite::Error::ConnectionClosed) => { + remove_connection_if_exists(connections, meta.poll_token); }, Err(err) => { eprintln!("error writing ws message: {}", err);