From 1d3ecf37ee879a0958e76747e729da2811895855 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Mon, 31 Jan 2022 11:03:20 -0500 Subject: [PATCH] consensus: remove unused closer construct (#7734) This is clearly a cob-web in the code, and may predict a solution to #7729, though this is difficult to backport because we don't have contexts in 0.35 --- internal/consensus/peer_state.go | 3 --- internal/consensus/reactor.go | 17 ----------------- 2 files changed, 20 deletions(-) diff --git a/internal/consensus/peer_state.go b/internal/consensus/peer_state.go index 7f3788cb4..f0130f0e1 100644 --- a/internal/consensus/peer_state.go +++ b/internal/consensus/peer_state.go @@ -8,7 +8,6 @@ import ( "time" cstypes "github.com/tendermint/tendermint/internal/consensus/types" - tmsync "github.com/tendermint/tendermint/internal/libs/sync" "github.com/tendermint/tendermint/libs/bits" "github.com/tendermint/tendermint/libs/log" tmtime "github.com/tendermint/tendermint/libs/time" @@ -46,7 +45,6 @@ type PeerState struct { Stats *peerStateStats `json:"stats"` broadcastWG sync.WaitGroup - closer *tmsync.Closer } // NewPeerState returns a new PeerState for the given node ID. @@ -54,7 +52,6 @@ func NewPeerState(logger log.Logger, peerID types.NodeID) *PeerState { return &PeerState{ peerID: peerID, logger: logger, - closer: tmsync.NewCloser(), PRS: cstypes.PeerRoundState{ Round: -1, ProposalPOLRound: -1, diff --git a/internal/consensus/reactor.go b/internal/consensus/reactor.go index 7f4dc4426..873326aa5 100644 --- a/internal/consensus/reactor.go +++ b/internal/consensus/reactor.go @@ -228,7 +228,6 @@ func (r *Reactor) OnStop() { // This is safe to perform with the lock since none of the peers require the // lock to complete any of the methods that the waitgroup is waiting on. for _, state := range r.peers { - state.closer.Close() state.broadcastWG.Wait() } r.mtx.Unlock() @@ -507,11 +506,6 @@ OUTER_LOOP: select { case <-ctx.Done(): return - case <-ps.closer.Done(): - // The peer is marked for removal via a PeerUpdate as the doneCh was - // explicitly closed to signal we should exit. - return - default: } @@ -770,11 +764,6 @@ OUTER_LOOP: select { case <-ctx.Done(): return - case <-ps.closer.Done(): - // The peer is marked for removal via a PeerUpdate as the doneCh was - // explicitly closed to signal we should exit. - return - default: } @@ -863,10 +852,6 @@ OUTER_LOOP: select { case <-ctx.Done(): return - case <-ps.closer.Done(): - // The peer is marked for removal via a PeerUpdate as the doneCh was - // explicitly closed to signal we should exit. - return default: } @@ -1055,8 +1040,6 @@ func (r *Reactor) processPeerUpdate(ctx context.Context, peerUpdate p2p.PeerUpda ps, ok := r.peers[peerUpdate.NodeID] if ok && ps.IsRunning() { // signal to all spawned goroutines for the peer to gracefully exit - ps.closer.Close() - go func() { // Wait for all spawned broadcast goroutines to exit before marking the // peer state as no longer running and removal from the peers map.