Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

our TCP listener is nonblocking so we *must* set the accepted stream to blocking explicitly #3154

Merged
merged 1 commit into from
Nov 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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