Skip to content

Commit

Permalink
close ws connection in case of BrokenPipe error (#2854)
Browse files Browse the repository at this point in the history
  • Loading branch information
kziemianek committed Jul 3, 2024
1 parent 644ffd7 commit d318e66
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions tee-worker/core/tls-websocket-server/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use log::*;
use mio::{event::Event, net::TcpStream, Poll, Ready, Token};
use rustls::{ServerSession, Session};
use std::{
format,
format, io,
string::{String, ToString},
sync::Arc,
time::Instant,
Expand Down Expand Up @@ -146,14 +146,19 @@ where
self.connection_token.0, e
);
},
Err(e) => match e {
tungstenite::Error::ConnectionClosed => return Ok(true),
tungstenite::Error::AlreadyClosed => return Ok(true),
_ => error!(
"Failed to read message from web-socket (connection {}): {:?}",
self.connection_token.0, e
),
},
Err(e) =>
return match e {
tungstenite::Error::Io(e) if e.kind() == io::ErrorKind::WouldBlock =>
Ok(false),
_ => {
trace!(
"Error while reading web-socket message (connection {}): {:?}",
self.connection_token.0,
e
);
Ok(true)
},
},
}
trace!("Read successful for connection {}", self.connection_token.0);
} else {
Expand Down

0 comments on commit d318e66

Please sign in to comment.