mirror of
https://github.com/mat-1/azalea.git
synced 2024-09-20 07:02:31 +00:00
shut down on broken pipe
This commit is contained in:
parent
ad8b1b7b24
commit
f2d21ad813
1 changed files with 11 additions and 1 deletions
|
@ -11,6 +11,7 @@ use crate::write::write_packet;
|
||||||
use azalea_auth::sessionserver::SessionServerError;
|
use azalea_auth::sessionserver::SessionServerError;
|
||||||
use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc};
|
use azalea_crypto::{Aes128CfbDec, Aes128CfbEnc};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
|
use log::info;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
@ -131,13 +132,22 @@ where
|
||||||
{
|
{
|
||||||
/// Write a packet to the server.
|
/// Write a packet to the server.
|
||||||
pub async fn write(&mut self, packet: W) -> std::io::Result<()> {
|
pub async fn write(&mut self, packet: W) -> std::io::Result<()> {
|
||||||
write_packet(
|
if let Err(e) = write_packet(
|
||||||
&packet,
|
&packet,
|
||||||
&mut self.write_stream,
|
&mut self.write_stream,
|
||||||
self.compression_threshold,
|
self.compression_threshold,
|
||||||
&mut self.enc_cipher,
|
&mut self.enc_cipher,
|
||||||
)
|
)
|
||||||
.await
|
.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.
|
/// End the connection.
|
||||||
|
|
Loading…
Reference in a new issue