Skip to content

Commit

Permalink
chore(p2p): remove unneeded stopMtx from MConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Jan 15, 2024
1 parent 80f3c9c commit 66186bd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/consensus/block_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (c *blockExecutor) ensureProcess(ctx context.Context, rs *cstypes.RoundStat
block := rs.ProposalBlock
crs := rs.CurrentRoundState
if crs.Params.Source != sm.ProcessProposalSource || !crs.MatchesBlock(block.Header, round) {
c.logger.Debug("CurrentRoundState is outdated, executing ProcessProposal", "crs", crs)
c.logger.Trace("CurrentRoundState is outdated, executing ProcessProposal", "crs", crs)
uncommittedState, err := c.blockExec.ProcessProposal(ctx, block, round, c.committedState, true)
if err != nil {
return fmt.Errorf("ProcessProposal abci method: %w", err)
Expand Down
8 changes: 1 addition & 7 deletions internal/p2p/conn/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ type MConnection struct {
// Closing quitRecvRouting will cause the recvRouting to eventually quit.
quitRecvRoutine chan struct{}

// used to ensure FlushStop and OnStop
// are safe to call concurrently.
stopMtx sync.Mutex
stopSignal <-chan struct{}

cancel context.CancelFunc
Expand Down Expand Up @@ -232,11 +229,8 @@ func (c *MConnection) getLastMessageAt() time.Time {

// stopServices stops the BaseService and timers and closes the quitSendRoutine.
// if the quitSendRoutine was already closed, it returns true, otherwise it returns false.
// It uses the stopMtx to ensure only one of FlushStop and OnStop can do this at a time.
// It doesn't lock, as we rely on the caller (eg. BaseService) locking
func (c *MConnection) stopServices() (alreadyStopped bool) {
c.stopMtx.Lock()
defer c.stopMtx.Unlock()

select {
case <-c.quitSendRoutine:
// already quit
Expand Down
1 change: 1 addition & 0 deletions internal/p2p/peermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ func (m *PeerManager) Disconnected(ctx context.Context, peerID types.NodeID) {
}

m.dialWaker.Wake()
m.logger.Debug("peer disconnected", "peer", peerID, "ready", ready)
}

// Errored reports a peer error, causing the peer to be evicted if it's
Expand Down

0 comments on commit 66186bd

Please sign in to comment.