mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
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
This commit is contained in:
parent
6ffc6c6ef7
commit
aaaf75d26e
1 changed files with 3 additions and 2 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue