From 6165c0873c51e9eef38615521c68ddf29cb0b0aa Mon Sep 17 00:00:00 2001 From: Gary Yu Date: Sat, 5 Jan 2019 01:08:44 +0800 Subject: [PATCH] fix: shutdown the tcpstream when we initiate to close a peer connection (#2288) --- p2p/src/conn.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/p2p/src/conn.rs b/p2p/src/conn.rs index d3efcb3c9..bce6edd9d 100644 --- a/p2p/src/conn.rs +++ b/p2p/src/conn.rs @@ -22,7 +22,7 @@ use std::fs::File; use std::io::{self, Read, Write}; -use std::net::TcpStream; +use std::net::{Shutdown, TcpStream}; use std::sync::{mpsc, Arc}; use std::{cmp, thread, time}; @@ -291,6 +291,7 @@ fn poll( .map(|a| a.to_string()) .unwrap_or("?".to_owned()) ); + let _ = conn.shutdown(Shutdown::Both); break; }