From 8f5a18b0fc841b6c11721ced346b10ab9ead655e Mon Sep 17 00:00:00 2001 From: jholdstock Date: Mon, 13 Feb 2023 15:47:53 +0000 Subject: [PATCH] ffldb_test: Use atomic types. --- database/ffldb/interface_test.go | 10 +++++----- database/go.mod | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/database/ffldb/interface_test.go b/database/ffldb/interface_test.go index 26390573d2..9af59d27f2 100644 --- a/database/ffldb/interface_test.go +++ b/database/ffldb/interface_test.go @@ -1,5 +1,5 @@ // Copyright (c) 2015-2016 The btcsuite developers -// Copyright (c) 2016-2020 The Decred developers +// Copyright (c) 2016-2023 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -2157,17 +2157,17 @@ func testConcurrentClose(tc *testContext) bool { // Start up a few readers and wait for them to acquire views. Each // reader waits for a signal to complete to ensure the transactions stay // open until they are explicitly signalled to be closed. - var activeReaders int32 + var activeReaders atomic.Int32 numReaders := 3 started := make(chan struct{}) finishReaders := make(chan struct{}) resultChan := make(chan bool, numReaders+1) reader := func() { err := tc.db.View(func(tx database.Tx) error { - atomic.AddInt32(&activeReaders, 1) + activeReaders.Add(1) started <- struct{}{} <-finishReaders - atomic.AddInt32(&activeReaders, -1) + activeReaders.Add(-1) return nil }) if err != nil { @@ -2206,7 +2206,7 @@ func testConcurrentClose(tc *testContext) bool { // active readers open. time.AfterFunc(time.Millisecond*250, func() { close(finishReaders) }) <-dbClosed - if nr := atomic.LoadInt32(&activeReaders); nr != 0 { + if nr := activeReaders.Load(); nr != 0 { tc.t.Errorf("Close did not appear to block with active "+ "readers: %d active", nr) return false diff --git a/database/go.mod b/database/go.mod index 17d7d5f0da..46a2593871 100644 --- a/database/go.mod +++ b/database/go.mod @@ -1,6 +1,6 @@ module github.com/decred/dcrd/database/v3 -go 1.17 +go 1.19 require ( github.com/decred/dcrd/chaincfg/chainhash v1.0.3