Skip to content

Commit

Permalink
GODRIVER-2236 Fix atomic op alignment and run linters on multiple arc…
Browse files Browse the repository at this point in the history
…hitectures. (#810)
  • Loading branch information
matthewdale authored Nov 23, 2021
1 parent 14339a4 commit 399ea1e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ EXAMPLES_TEST_PKGS = $(shell etc/list_test_pkgs.sh ./examples)
PKGS = $(BSON_PKGS) $(EVENT_PKGS) $(MONGO_PKGS) $(UNSTABLE_PKGS) $(TAG_PKG) $(EXAMPLES_PKGS)
TEST_PKGS = $(BSON_TEST_PKGS) $(EVENT_TEST_PKGS) $(MONGO_TEST_PKGS) $(UNSTABLE_TEST_PKGS) $(TAG_PKG) $(EXAMPLES_TEST_PKGS)
ATLAS_URIS = "$(ATLAS_FREE)" "$(ATLAS_REPLSET)" "$(ATLAS_SHARD)" "$(ATLAS_TLS11)" "$(ATLAS_TLS12)" "$(ATLAS_FREE_SRV)" "$(ATLAS_REPLSET_SRV)" "$(ATLAS_SHARD_SRV)" "$(ATLAS_TLS11_SRV)" "$(ATLAS_TLS12_SRV)" "$(ATLAS_SERVERLESS)" "$(ATLAS_SERVERLESS_SRV)"
GODISTS=linux/amd64 linux/386 linux/arm64 linux/arm linux/s390x

TEST_TIMEOUT = 1800

Expand Down Expand Up @@ -59,7 +60,13 @@ fmt:

.PHONY: lint
lint:
golangci-lint run --config .golangci.yml ./...
for dist in $(GODISTS); do \
goos=$$(echo $$dist | cut -d/ -f 1) ; \
goarch=$$(echo $$dist | cut -d/ -f 2) ; \
command="GOOS=$$goos GOARCH=$$goarch golangci-lint run --config .golangci.yml ./..." ; \
echo $$command ; \
eval $$command ; \
done

.PHONY: test
test:
Expand Down
7 changes: 6 additions & 1 deletion mongo/integration/mtest/mongotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ type WriteConcernErrorData struct {

// T is a wrapper around testing.T.
type T struct {
// connsCheckedOut is the net number of connections checked out during test execution.
// It must be accessed using the atomic package and should be at the beginning of the struct.
// - atomic bug: https://pkg.go.dev/sync/atomic#pkg-note-BUG
// - suggested layout: https://go101.org/article/memory-layout.html
connsCheckedOut int64

*testing.T

// members for only this T instance
Expand All @@ -104,7 +110,6 @@ type T struct {
dataLake *bool
ssl *bool
collCreateOpts bson.D
connsCheckedOut int64 // net number of connections checked out during test execution
requireAPIVersion *bool

// options copied to sub-tests
Expand Down
9 changes: 7 additions & 2 deletions x/mongo/driver/topology/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ func connectionStateString(state int64) string {

// Server is a single server within a topology.
type Server struct {
cfg *serverConfig
address address.Address
// connectionstate must be accessed using the atomic package and should be at the beginning of
// the struct.
// - atomic bug: https://pkg.go.dev/sync/atomic#pkg-note-BUG
// - suggested layout: https://go101.org/article/memory-layout.html
connectionstate int64

cfg *serverConfig
address address.Address

// connection related fields
pool *pool

Expand Down

0 comments on commit 399ea1e

Please sign in to comment.