From ec6fbb1f2d517b7b8e69961052adf7136f3af773 Mon Sep 17 00:00:00 2001 From: Tony Redondo Date: Tue, 19 Nov 2024 10:28:08 +0100 Subject: [PATCH] internal/civisibility: fix RWMutex usages (#2982) --- .../integrations/gotesting/instrumentation.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/civisibility/integrations/gotesting/instrumentation.go b/internal/civisibility/integrations/gotesting/instrumentation.go index c7b18a92c0..1c3be06223 100644 --- a/internal/civisibility/integrations/gotesting/instrumentation.go +++ b/internal/civisibility/integrations/gotesting/instrumentation.go @@ -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 @@ -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()) }