Vet/race fixes (#4421)

This addresses all found vet/race fixes in community edition.

---------

Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
This commit is contained in:
Jeff MitchellandDamian Debkowski authored and GitHub committed 2024-02-21 16:32:26 -05:00
1 parent 4535af25aa
commit 014a5a7aae
46 files changed
+411 -176

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ var (
TcpHandlerName = "tcp"
// handlers is the map of registered handlers
handlers sync.Map
handlers *sync.Map = new(sync.Map)
// ErrUnknownProtocol specifies the provided protocol has no registered handler
ErrUnknownProtocol = errors.New("proxy: handler not found for protocol")
@@ -9,10 +9,10 @@ import (
)
// ProxyState contains the current state of proxies in this process.
var ProxyState proxyState
var ProxyState proxyState = proxyState{proxyCount: new(atomic.Int64)}
type proxyState struct {
proxyCount atomic.Int64
proxyCount *atomic.Int64
}
// CurrentProxiedConnections returns the current number of ongoing proxied
@@ -6,6 +6,7 @@ package proxy
import (
"net/http"
"net/http/httptest"
"sync/atomic"
"testing"
"github.com/stretchr/testify/assert"
@@ -14,7 +15,7 @@ import (
func TestProxyStateHelpers(t *testing.T) {
old := ProxyState
ProxyState = proxyState{}
ProxyState = proxyState{proxyCount: new(atomic.Int64)}
t.Cleanup(func() {
ProxyState = old
})
+2 -2
View File
@@ -24,7 +24,7 @@ func TestRegisterHandler(t *testing.T) {
t.Cleanup(func() {
handlers = oldHandler
})
handlers = sync.Map{}
handlers = new(sync.Map)
err := RegisterHandler("protocol", fn)
require.NoError(err)
@@ -47,7 +47,7 @@ func TestAlwaysTcpGetHandler(t *testing.T) {
t.Cleanup(func() {
handlers = oldHandler
})
handlers = sync.Map{}
handlers = new(sync.Map)
_, err := tcpOnly("wid", nil)
assert.ErrorIs(err, ErrUnknownProtocol)