aquatic_ws: don't handle connection closed same as other errors

This commit is contained in:
Joakim Frostegård 2020-05-23 14:17:03 +02:00
parent ae92785484
commit 572aa632b6
2 changed files with 9 additions and 5 deletions

View file

@ -9,8 +9,6 @@
* is it even necessary to check if event is readable in poll, since that * is it even necessary to check if event is readable in poll, since that
is all we're listening for? is all we're listening for?
* privdrop * privdrop
* on error because connection is closed, don't handle the same as for io
errors etc
## aquatic_udp ## aquatic_udp
* mio: set oneshot for epoll and kqueue? otherwise, stop reregistering? * mio: set oneshot for epoll and kqueue? otherwise, stop reregistering?

View file

@ -182,7 +182,12 @@ pub fn run_handshakes_and_read_messages(
}, },
Err(Io(err)) if err.kind() == ErrorKind::WouldBlock => { Err(Io(err)) if err.kind() == ErrorKind::WouldBlock => {
break; break;
} },
Err(tungstenite::Error::ConnectionClosed) => {
remove_connection_if_exists(connections, poll_token);
break
},
Err(err) => { Err(err) => {
eprintln!("error reading messages: {}", 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()){ match established_ws.ws.write_message(out_message.to_ws_message()){
Ok(()) => {}, Ok(()) => {},
Err(Io(err)) if err.kind() == ErrorKind::WouldBlock => { Err(Io(err)) if err.kind() == ErrorKind::WouldBlock => {},
continue; Err(tungstenite::Error::ConnectionClosed) => {
remove_connection_if_exists(connections, meta.poll_token);
}, },
Err(err) => { Err(err) => {
eprintln!("error writing ws message: {}", err); eprintln!("error writing ws message: {}", err);