diff options
| author | mat <github@matdoes.dev> | 2022-11-09 18:18:55 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-11-09 18:18:55 -0600 |
| commit | f2d21ad8136d02f7d67074117be1e233694ccc5d (patch) | |
| tree | 67081761912812ef79e389483a9a961ab7eca372 /azalea-protocol | |
| parent | ad8b1b7b2405b39d0f86b7adb00df7662dcd1a19 (diff) | |
| download | azalea-drasl-f2d21ad8136d02f7d67074117be1e233694ccc5d.tar.xz | |
shut down on broken pipe
Diffstat (limited to 'azalea-protocol')
| -rw-r--r-- | azalea-protocol/src/connect.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs index c0c1a622..2400c712 100644 --- a/azalea-protocol/src/connect.rs +++ b/azalea-protocol/src/connect.rs @@ -11,6 +11,7 @@ use crate::write::write_packet; use azalea_auth::sessionserver::SessionServerError; use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc}; use bytes::BytesMut; +use log::info; use std::fmt::Debug; use std::marker::PhantomData; use std::net::SocketAddr; @@ -131,13 +132,22 @@ where { /// Write a packet to the server. pub async fn write(&mut self, packet: W) -> std::io::Result<()> { - write_packet( + if let Err(e) = write_packet( &packet, &mut self.write_stream, self.compression_threshold, &mut self.enc_cipher, ) .await + { + // detect broken pipe + if e.kind() == std::io::ErrorKind::BrokenPipe { + info!("Broken pipe, shutting down connection.") + self.shutdown(); + } + return Err(e); + } + Ok(()) } /// End the connection. |
