Skip to content

Commit

Permalink
our TCP listener is nonblocking so we *must* set the accepted stream …
Browse files Browse the repository at this point in the history
…to blocking explicitly... (#3154)
  • Loading branch information
antiochp authored and hashmap committed Nov 30, 2019
1 parent c46343f commit 7f7d51a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions p2p/src/serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7f7d51a

Please sign in to comment.