Skip to content

Commit

Permalink
Adding a Mutex to mockSAPaused to Solve the WARNING: DATA RACE Is…
Browse files Browse the repository at this point in the history
…sue.

fixes: letsencrypt#7697
  • Loading branch information
ldlb9527 committed Sep 9, 2024
1 parent 77fcc8f commit ef95132
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/admin/pause_identifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path"
"strings"
"sync"
"testing"

blog "github.com/letsencrypt/boulder/log"
Expand Down Expand Up @@ -83,11 +84,15 @@ func TestReadingPauseCSV(t *testing.T) {
// received, and returns the number of identifiers as a
// PauseIdentifiersResponse. It does not maintain state of repaused identifiers.
type mockSAPaused struct {
mutex sync.Mutex
sapb.StorageAuthorityClient
reqs []*sapb.PauseRequest
}

func (msa *mockSAPaused) PauseIdentifiers(ctx context.Context, in *sapb.PauseRequest, _ ...grpc.CallOption) (*sapb.PauseIdentifiersResponse, error) {
msa.mutex.Lock()
defer msa.mutex.Unlock()

msa.reqs = append(msa.reqs, in)

return &sapb.PauseIdentifiersResponse{Paused: int64(len(in.Identifiers))}, nil
Expand Down Expand Up @@ -181,7 +186,7 @@ func TestPauseIdentifiers(t *testing.T) {

// Default to a working mock SA implementation
if testCase.saImpl == nil {
testCase.saImpl = &mockSAPaused{}
testCase.saImpl = &mockSAPaused{mutex: sync.Mutex{}}
}
a := admin{sac: testCase.saImpl, log: log}

Expand Down

0 comments on commit ef95132

Please sign in to comment.