p2p: ensure closed channels stop receiving service (#8979)

Once these channels are closed, we should not continue to service them, as they
will never again deliver nonzero values.
This commit is contained in:
M. J. Fromberger
2022-07-11 16:34:05 -07:00
committed by GitHub
parent 451e697331
commit f98de20f7e

View File

@@ -427,8 +427,10 @@ func (r *Router) routeChannel(
) {
for {
select {
case envelope := <-outCh:
if envelope.IsZero() {
case envelope, ok := <-outCh:
if !ok {
return
} else if envelope.IsZero() {
continue
}
// Mark the envelope with the channel ID to allow sendPeer() to pass
@@ -507,7 +509,10 @@ func (r *Router) routeChannel(
}
}
case peerError := <-errCh:
case peerError, ok := <-errCh:
if !ok {
return
}
maxPeerCapacity := r.peerManager.HasMaxPeerCapacity()
r.logger.Error("peer error",
"peer", peerError.NodeID,