From 24b5dbb0bd86b7846a8084088374da3e6498bddd Mon Sep 17 00:00:00 2001 From: antiochp <30642645+antiochp@users.noreply.github.com> Date: Sat, 30 Nov 2019 22:06:02 +0000 Subject: [PATCH] our TCP listener is nonblocking so we *must* set the accepted stream to blocking explicitly... --- p2p/src/serv.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/p2p/src/serv.rs b/p2p/src/serv.rs index bd9476ddbc..7e8e87105f 100644 --- a/p2p/src/serv.rs +++ b/p2p/src/serv.rs @@ -84,6 +84,14 @@ impl Server { match listener.accept() { Ok((stream, peer_addr)) => { + // We want out TCP stream to be in blocking mode. + // The TCP listener is in nonblocking mode so we *must* explicitly + // move the accepted TCP stream into blocking mode (or all kinds of + // bad things can and will happen). + // A nonblocking TCP listener will accept nonblocking TCP streams which + // we do not want. + stream.set_nonblocking(false)?; + let peer_addr = PeerAddr(peer_addr); if self.check_undesirable(&stream) {