peer: No error log on unexpected EOF.

This modifies the error handling path in the peer read loop such that it
will no longer log an error when the error is io.ErrUnexpectedEOF.  This
is being done because that error is almost always the result of a peer
being remotely disconnected and thus it isn't useful information to log.

However, since it might actually be due to a malformed message, a reject
message is still queued up to be sent back to the peer (which will
simply be discarded if the peer disconnected) before it is disconnected.

While it would be ideal to only log if it's not due to a disconnect, and
the code already attempts to handle that, it's not 100% possible to
detect upon the read returning an error without attempting to read again
which will not happen until the next loop iteration.
This commit is contained in:
Dave Collins 2016-11-08 14:06:37 -06:00
parent e8f63bc295
commit 089611a61b
No known key found for this signature in database
GPG key ID: B8904D9D9C93D1F2

View file

@ -1422,7 +1422,9 @@ out:
// remote peer has not disconnected. // remote peer has not disconnected.
if p.shouldHandleReadError(err) { if p.shouldHandleReadError(err) {
errMsg := fmt.Sprintf("Can't read message from %s: %v", p, err) errMsg := fmt.Sprintf("Can't read message from %s: %v", p, err)
log.Errorf(errMsg) if err != io.ErrUnexpectedEOF {
log.Errorf(errMsg)
}
// Push a reject message for the malformed message and wait for // Push a reject message for the malformed message and wait for
// the message to be sent before disconnecting. // the message to be sent before disconnecting.