Skip to content

Commit

Permalink
internal/civisibility: fix RWMutex usages (#2982)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo authored and darccio committed Nov 21, 2024
1 parent ca6322f commit ec6fbb1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/civisibility/integrations/gotesting/instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ func getInstrumentationMetadata(fn *runtime.Func) *instrumentationMetadata {

// setInstrumentationMetadata stores an instrumentation metadata for a given *runtime.Func.
func setInstrumentationMetadata(fn *runtime.Func, metadata *instrumentationMetadata) {
instrumentationMapMutex.RLock()
defer instrumentationMapMutex.RUnlock()
instrumentationMapMutex.Lock()
defer instrumentationMapMutex.Unlock()
instrumentationMap[fn] = metadata
}

// createTestMetadata creates the CI visibility test metadata associated with a given *testing.T, *testing.B, *testing.common
func createTestMetadata(tb testing.TB) *testExecutionMetadata {
ciVisibilityTestMetadataMutex.RLock()
defer ciVisibilityTestMetadataMutex.RUnlock()
ciVisibilityTestMetadataMutex.Lock()
defer ciVisibilityTestMetadataMutex.Unlock()
execMetadata := &testExecutionMetadata{}
ciVisibilityTestMetadata[reflect.ValueOf(tb).UnsafePointer()] = execMetadata
return execMetadata
Expand All @@ -135,8 +135,8 @@ func getTestMetadataFromPointer(ptr unsafe.Pointer) *testExecutionMetadata {

// deleteTestMetadata delete the CI visibility test metadata associated with a given *testing.T, *testing.B, *testing.common
func deleteTestMetadata(tb testing.TB) {
ciVisibilityTestMetadataMutex.RLock()
defer ciVisibilityTestMetadataMutex.RUnlock()
ciVisibilityTestMetadataMutex.Lock()
defer ciVisibilityTestMetadataMutex.Unlock()
delete(ciVisibilityTestMetadata, reflect.ValueOf(tb).UnsafePointer())
}

Expand Down

0 comments on commit ec6fbb1

Please sign in to comment.