forked from TrueCloudLab/neoneo-go
network: fix logic and logging for sendVersion() errors
It doesn't make sense trying to read from a broken connection and the disconnect is to be logger from the server on unregistration.
This commit is contained in:
parent
b5f234ddef
commit
2192b6602a
1 changed files with 15 additions and 15 deletions
|
@ -82,22 +82,22 @@ func (t *TCPTransport) handleConn(conn net.Conn) {
|
||||||
t.server.register <- p
|
t.server.register <- p
|
||||||
|
|
||||||
// When a new peer is connected we send out our version immediately.
|
// When a new peer is connected we send out our version immediately.
|
||||||
if err := t.server.sendVersion(p); err != nil {
|
err = t.server.sendVersion(p)
|
||||||
t.log.Error("error on sendVersion", zap.Stringer("addr", p.RemoteAddr()), zap.Error(err))
|
if err == nil {
|
||||||
}
|
r := io.NewBinReaderFromIO(p.conn)
|
||||||
r := io.NewBinReaderFromIO(p.conn)
|
for {
|
||||||
for {
|
msg := &Message{}
|
||||||
msg := &Message{}
|
err = msg.Decode(r)
|
||||||
err = msg.Decode(r)
|
|
||||||
|
|
||||||
if err == payload.ErrTooManyHeaders {
|
if err == payload.ErrTooManyHeaders {
|
||||||
t.log.Warn("not all headers were processed")
|
t.log.Warn("not all headers were processed")
|
||||||
r.Err = nil
|
r.Err = nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err = t.server.handleMessage(p, msg); err != nil {
|
if err = t.server.handleMessage(p, msg); err != nil {
|
||||||
break
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.server.unregister <- peerDrop{p, err}
|
t.server.unregister <- peerDrop{p, err}
|
||||||
|
|
Loading…
Reference in a new issue