mirror of
https://github.com/tendermint/tendermint.git
synced 2026-05-20 22:21:28 +00:00
p2p: accept should not abort on first error
This commit is contained in:
@@ -470,14 +470,17 @@ func (r *Router) dialSleep(ctx context.Context) {
|
||||
func (r *Router) acceptPeers(ctx context.Context, transport Transport) {
|
||||
for {
|
||||
conn, err := transport.Accept(ctx)
|
||||
switch err {
|
||||
case nil:
|
||||
case io.EOF:
|
||||
r.logger.Debug("stopping accept routine", "transport", transport)
|
||||
switch {
|
||||
case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded):
|
||||
r.logger.Debug("stopping accept routine", "transport", transport, "err", "context canceled")
|
||||
return
|
||||
default:
|
||||
case errors.Is(err, io.EOF):
|
||||
r.logger.Debug("stopping accept routine", "transport", transport, "err", "EOF")
|
||||
return
|
||||
case err != nil:
|
||||
// in this case we got an error from the net.Listener.
|
||||
r.logger.Error("failed to accept connection", "transport", transport, "err", err)
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
incomingIP := conn.RemoteEndpoint().IP
|
||||
@@ -489,7 +492,7 @@ func (r *Router) acceptPeers(ctx context.Context, transport Transport) {
|
||||
"close_err", closeErr,
|
||||
)
|
||||
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
// Spawn a goroutine for the handshake, to avoid head-of-line blocking.
|
||||
|
||||
Reference in New Issue
Block a user