From 891fe75ffc1571001608db71e1fe8dc2cd725eaf Mon Sep 17 00:00:00 2001 From: Zhang Jingqiang Date: Wed, 23 Aug 2023 14:46:01 +0800 Subject: [PATCH] g3keymess: ignore more early connection errors --- g3keymess/src/serve/task/multiplex.rs | 8 +++++++- g3keymess/src/serve/task/simplex.rs | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/g3keymess/src/serve/task/multiplex.rs b/g3keymess/src/serve/task/multiplex.rs index 5bece6de7..f6e9a42ed 100644 --- a/g3keymess/src/serve/task/multiplex.rs +++ b/g3keymess/src/serve/task/multiplex.rs @@ -109,7 +109,13 @@ impl KeylessTask { msg_count += 1; } Ok(false) => return Ok(()), - Err(e) => return Err(ServerTaskError::ReadFailed(e)), + Err(e) => { + return if msg_count == 0 { + Err(ServerTaskError::ConnectionClosedEarly) + } else { + Err(ServerTaskError::ReadFailed(e)) + }; + } } } r = self.ctx.reload_notifier.recv() => { diff --git a/g3keymess/src/serve/task/simplex.rs b/g3keymess/src/serve/task/simplex.rs index 780415ca4..961226cb9 100644 --- a/g3keymess/src/serve/task/simplex.rs +++ b/g3keymess/src/serve/task/simplex.rs @@ -49,7 +49,11 @@ impl KeylessTask { } Ok(false) => break, Err(e) => { - self.log_task_err(ServerTaskError::ReadFailed(e)); + if msg_count == 0 { + self.log_task_err(ServerTaskError::ConnectionClosedEarly); + } else { + self.log_task_err(ServerTaskError::ReadFailed(e)); + } break; } }