From 99494e148be72a84ebecb3c4a322c8234d05f660 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Wed, 10 Nov 2021 14:28:05 +0100 Subject: [PATCH] always shut down connection properly --- src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6b35562..c2cb61f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -386,12 +386,12 @@ impl RequestHandle { Err((status, msg)) => self.send_header(status, msg).await, }; - if let Err(e) = result { - Err(format!("{} error:{}", self.log_line, e)) - } else if let Err(e) = self.stream.shutdown().await { - Err(format!("{} error:{}", self.log_line, e)) - } else { - Ok(self.log_line) + let close_result = self.stream.shutdown().await; + + match (result, close_result) { + (Err(e), _) => Err(format!("{} error:{}", self.log_line, e)), + (Ok(_), Err(e)) => Err(format!("{} error:{}", self.log_line, e)), + (Ok(_), Ok(_)) => Ok(self.log_line), } }