libs: wrap mutexes for build flag with godeadlock (#5126)

## Description

This PR wraps the stdlib sync.(RW)Mutex & godeadlock.(RW)Mutex. This enables using go-deadlock via a build flag instead of using sed to replace sync with godeadlock in all files

Closes: #3242
This commit is contained in:
Marko
2020-07-20 07:55:09 +00:00
committed by GitHub
parent 8cdb53c811
commit 2ac5a559b4
61 changed files with 182 additions and 145 deletions
+3 -2
View File
@@ -15,6 +15,7 @@ import (
"github.com/tendermint/tendermint/libs/log"
tmmath "github.com/tendermint/tendermint/libs/math"
tmos "github.com/tendermint/tendermint/libs/os"
tmsync "github.com/tendermint/tendermint/libs/sync"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/proxy"
"github.com/tendermint/tendermint/types"
@@ -43,7 +44,7 @@ type CListMempool struct {
// Exclusive mutex for Update method to prevent concurrent execution of
// CheckTx or ReapMaxBytesMaxGas(ReapMaxTxs) methods.
updateMtx sync.RWMutex
updateMtx tmsync.RWMutex
preCheck PreCheckFunc
postCheck PostCheckFunc
@@ -681,7 +682,7 @@ type txCache interface {
// mapTxCache maintains a LRU cache of transactions. This only stores the hash
// of the tx, due to memory concerns.
type mapTxCache struct {
mtx sync.Mutex
mtx tmsync.Mutex
size int
cacheMap map[[TxKeySize]byte]*list.Element
list *list.List
+2 -2
View File
@@ -3,12 +3,12 @@ package mempool
import (
"fmt"
"math"
"sync"
"time"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/clist"
"github.com/tendermint/tendermint/libs/log"
tmsync "github.com/tendermint/tendermint/libs/sync"
"github.com/tendermint/tendermint/p2p"
protomem "github.com/tendermint/tendermint/proto/tendermint/mempool"
"github.com/tendermint/tendermint/types"
@@ -39,7 +39,7 @@ type Reactor struct {
}
type mempoolIDs struct {
mtx sync.RWMutex
mtx tmsync.RWMutex
peerMap map[p2p.ID]uint16
nextID uint16 // assumes that a node will never have over 65536 active peers
activeIDs map[uint16]struct{} // used to check if a given peerID key is used, the value doesn't matter