From aaaf75d26ec5a4e480920039950961e484bd2d8c Mon Sep 17 00:00:00 2001 From: zelig Date: Mon, 18 Sep 2017 13:44:14 +0200 Subject: [PATCH] p2p: add error check to SetWriteDeadline call in rlpx 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. This commit adds error checking on the SetWriteDeadline call and only tries to send the disconnect reason message if there is no error --- p2p/rlpx.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/p2p/rlpx.go b/p2p/rlpx.go index 24037ecc13..b97f9e89c0 100644 --- a/p2p/rlpx.go +++ b/p2p/rlpx.go @@ -108,8 +108,9 @@ 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) + if err = t.fd.SetWriteDeadline(time.Now().Add(discWriteTimeout)); err == nil { + SendItems(t.rw, discMsg, r) + } } } t.fd.Close()