From 026dd1ed9c058f38817a89d023490be77d578156 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 30 Sep 2020 23:35:51 +0200 Subject: [PATCH] main: close tx half of sockets with closed rx half fixes Gitea issue #9 --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 9785d83..bc2262b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -194,7 +194,9 @@ fn main() -> ! { if ! socket.is_active() { let _ = socket.listen(TCP_PORT); session.reset(); - } else if socket.can_send() && socket.can_recv() && socket.send_capacity() - socket.send_queue() > 1024 { + } else if socket.may_send() && !socket.may_recv() { + socket.close() + } else if socket.can_send() && socket.can_recv() { match socket.recv(|buf| session.feed(buf)) { Ok(SessionInput::Nothing) => {} Ok(SessionInput::Command(command)) => match command {