diff options
author | Anton Evangelatov <anton.evangelatov@gmail.com> | 2018-02-22 18:41:06 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-02-22 18:41:06 +0800 |
commit | 1e457b659989478004329c2f3a82b5ac67b32cbf (patch) | |
tree | 5c29f77423957484852f6efd790834f916ae643b /p2p/rlpx.go | |
parent | bb5349b15463255d269870fec9839a942eeecc1a (diff) | |
download | go-tangerine-1e457b659989478004329c2f3a82b5ac67b32cbf.tar.gz go-tangerine-1e457b659989478004329c2f3a82b5ac67b32cbf.tar.zst go-tangerine-1e457b659989478004329c2f3a82b5ac67b32cbf.zip |
p2p: don't send DiscReason when using net.Pipe (#16004)
Diffstat (limited to 'p2p/rlpx.go')
-rw-r--r-- | p2p/rlpx.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/p2p/rlpx.go b/p2p/rlpx.go index 24037ecc1..e65a0b604 100644 --- a/p2p/rlpx.go +++ b/p2p/rlpx.go @@ -108,8 +108,14 @@ func (t *rlpx) close(err error) { // Tell the remote end why we're disconnecting if possible. if t.rw != nil { if r, ok := err.(DiscReason); ok && r != DiscNetworkError { - t.fd.SetWriteDeadline(time.Now().Add(discWriteTimeout)) - SendItems(t.rw, discMsg, r) + // rlpx tries to send DiscReason to disconnected peer + // if the connection is net.Pipe (in-memory simulation) + // it hangs forever, since net.Pipe does not implement + // a write deadline. Because of this only try to send + // the disconnect reason message if there is no error. + if err := t.fd.SetWriteDeadline(time.Now().Add(discWriteTimeout)); err == nil { + SendItems(t.rw, discMsg, r) + } } } t.fd.Close() |