Ver código fonte

darkirc: deathloop fix, clients(bots) closing unexpectly causing an unhandled read buffer of 0 to continue endlessly

dasman 1 ano atrás
pai
commit
2acd3c60bb
1 arquivos alterados com 6 adições e 0 exclusões
  1. 6 0
      bin/darkirc/src/irc/client.rs

+ 6 - 0
bin/darkirc/src/irc/client.rs

@@ -164,6 +164,12 @@ impl Client {
             futures::select! {
             futures::select! {
                 // Process message from the IRC client
                 // Process message from the IRC client
                 r = reader.read_line(&mut line).fuse() => {
                 r = reader.read_line(&mut line).fuse() => {
+                    // If client closed unexpectedly, we disconnect.
+                    if let Ok(0) = r {
+                        error!("[IRC CLIENT] Read failed for {}: Client disconnected", self.addr);
+                        self.incoming.unsubscribe().await;
+                        return Err(Error::ChannelStopped)
+                    }
                     // If something failed during reading, we disconnect.
                     // If something failed during reading, we disconnect.
                     if let Err(e) = r {
                     if let Err(e) = r {
                         error!("[IRC CLIENT] Read failed for {}: {}", self.addr, e);
                         error!("[IRC CLIENT] Read failed for {}: {}", self.addr, e);