mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
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
|
||||
|
||||
// When a new peer is connected we send out our version immediately.
|
||||
if err := t.server.sendVersion(p); err != nil {
|
||||
t.log.Error("error on sendVersion", zap.Stringer("addr", p.RemoteAddr()), zap.Error(err))
|
||||
}
|
||||
r := io.NewBinReaderFromIO(p.conn)
|
||||
for {
|
||||
msg := &Message{}
|
||||
err = msg.Decode(r)
|
||||
err = t.server.sendVersion(p)
|
||||
if err == nil {
|
||||
r := io.NewBinReaderFromIO(p.conn)
|
||||
for {
|
||||
msg := &Message{}
|
||||
err = msg.Decode(r)
|
||||
|
||||
if err == payload.ErrTooManyHeaders {
|
||||
t.log.Warn("not all headers were processed")
|
||||
r.Err = nil
|
||||
} else if err != nil {
|
||||
break
|
||||
}
|
||||
if err = t.server.handleMessage(p, msg); err != nil {
|
||||
break
|
||||
if err == payload.ErrTooManyHeaders {
|
||||
t.log.Warn("not all headers were processed")
|
||||
r.Err = nil
|
||||
} else if err != nil {
|
||||
break
|
||||
}
|
||||
if err = t.server.handleMessage(p, msg); err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
t.server.unregister <- peerDrop{p, err}
|
||||
|
|
Loading…
Reference in a new issue