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 09:55:09 +02:00
committed by GitHub
parent 8cdb53c811
commit 2ac5a559b4
61 changed files with 182 additions and 145 deletions

View File

@@ -9,8 +9,8 @@ import (
"net/http"
"net/url"
"strings"
"sync"
tmsync "github.com/tendermint/tendermint/libs/sync"
types "github.com/tendermint/tendermint/rpc/jsonrpc/types"
)
@@ -99,7 +99,7 @@ type Client struct {
client *http.Client
mtx sync.Mutex
mtx tmsync.Mutex
nextReqID int
}
@@ -260,7 +260,7 @@ type jsonRPCBufferedRequest struct {
type RequestBatch struct {
client *Client
mtx sync.Mutex
mtx tmsync.Mutex
requests []*jsonRPCBufferedRequest
}

View File

@@ -14,6 +14,7 @@ import (
tmrand "github.com/tendermint/tendermint/libs/rand"
"github.com/tendermint/tendermint/libs/service"
tmsync "github.com/tendermint/tendermint/libs/sync"
types "github.com/tendermint/tendermint/rpc/jsonrpc/types"
)
@@ -56,7 +57,7 @@ type WSClient struct { // nolint: maligned
wg sync.WaitGroup
mtx sync.RWMutex
mtx tmsync.RWMutex
sentLastPingAt time.Time
reconnecting bool
nextReqID int

View File

@@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmsync "github.com/tendermint/tendermint/libs/sync"
types "github.com/tendermint/tendermint/rpc/jsonrpc/types"
)
@@ -21,7 +21,7 @@ var wsCallTimeout = 5 * time.Second
type myHandler struct {
closeConnAfterRead bool
mtx sync.RWMutex
mtx tmsync.RWMutex
}
var upgrader = websocket.Upgrader{