Skip to content

Commit 7f7d51a

Browse files
antiochphashmap
authored andcommitted
our TCP listener is nonblocking so we *must* set the accepted stream to blocking explicitly... (#3154)
1 parent c46343f commit 7f7d51a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

p2p/src/serv.rs

+8
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ impl Server {
8484

8585
match listener.accept() {
8686
Ok((stream, peer_addr)) => {
87+
// We want out TCP stream to be in blocking mode.
88+
// The TCP listener is in nonblocking mode so we *must* explicitly
89+
// move the accepted TCP stream into blocking mode (or all kinds of
90+
// bad things can and will happen).
91+
// A nonblocking TCP listener will accept nonblocking TCP streams which
92+
// we do not want.
93+
stream.set_nonblocking(false)?;
94+
8795
let peer_addr = PeerAddr(peer_addr);
8896

8997
if self.check_undesirable(&stream) {

0 commit comments

Comments
 (0)