Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/civisibility: fix RWMutex usages #2982

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading