From 17bac1d90f08e91ada46f7781c3dcb36c3ee91ce Mon Sep 17 00:00:00 2001 From: Maciej Hirsz Date: Wed, 6 Nov 2019 16:41:40 +0100 Subject: [PATCH] Log errors --- actix-web-actors/Cargo.toml | 1 + actix-web-actors/src/ws.rs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/actix-web-actors/Cargo.toml b/actix-web-actors/Cargo.toml index 356109da5..8e5768c1d 100644 --- a/actix-web-actors/Cargo.toml +++ b/actix-web-actors/Cargo.toml @@ -24,6 +24,7 @@ actix-http = "0.2.5" actix-codec = "0.1.2" bytes = "0.4" futures = "0.1.25" +log = "0.4" [dev-dependencies] env_logger = "0.6" diff --git a/actix-web-actors/src/ws.rs b/actix-web-actors/src/ws.rs index 787cb80fc..9bd286813 100644 --- a/actix-web-actors/src/ws.rs +++ b/actix-web-actors/src/ws.rs @@ -1,4 +1,6 @@ //! Websocket integration +use log::error; + use std::collections::VecDeque; use std::io; @@ -556,7 +558,7 @@ where let data = data.unwrap_or_else(|| BytesMut::new()); if self.collector.is_initialized() { - // Previous collection was already finalized + error!("Initialize a new fragmented sequence while another is active."); return Err(ProtocolError::NoContinuation); } @@ -567,7 +569,7 @@ where let data = data.unwrap_or_else(|| BytesMut::new()); if self.collector.is_initialized() { - // Previous collection was already finalized + error!("Initialize a new fragmented sequence while another is active."); return Err(ProtocolError::NoContinuation); } @@ -582,7 +584,10 @@ where buf.extend_from_slice(data); } // Uninitialized continuation - _ => return Err(ProtocolError::NoContinuation), + _ => { + error!("Trying to continue an uninitialized sequence of fragmented frames."); + return Err(ProtocolError::NoContinuation); + } } None @@ -602,7 +607,10 @@ where Some(Message::Binary(buf.freeze())) } // Uninitialized continuation - Collector::Uninitialized => return Err(ProtocolError::NoContinuation), + Collector::Uninitialized => { + error!("Trying to end an uninitialized sequence of fragmented frames."); + return Err(ProtocolError::NoContinuation); + } } } };