From 2a7162e9bb669862009ceea015e41e536297534f Mon Sep 17 00:00:00 2001 From: akorotkov Date: Mon, 4 Nov 2024 09:31:52 +0200 Subject: [PATCH] use RW lock --- pkg/service/client_manager.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/service/client_manager.go b/pkg/service/client_manager.go index ac022ef4..f3056684 100644 --- a/pkg/service/client_manager.go +++ b/pkg/service/client_manager.go @@ -37,7 +37,7 @@ func (f *DefaultClientFactory) NewClientWithPolicyAndHost( // ClientManagerImpl implements [ClientManager]. // Is responsible for creating and closing backup clients. type ClientManagerImpl struct { - mu sync.Mutex + mu sync.RWMutex clients map[*model.AerospikeCluster]*clientInfo clientFactory AerospikeClientFactory closeDelay time.Duration @@ -75,8 +75,8 @@ func (cm *ClientManagerImpl) GetClient(cluster *model.AerospikeCluster) (*backup // getExistingClient tries to get an existing client from the cache. // Returns nil if client doesn't exist. func (cm *ClientManagerImpl) getExistingClient(cluster *model.AerospikeCluster) *backup.Client { - cm.mu.Lock() - defer cm.mu.Unlock() + cm.mu.RLock() + defer cm.mu.RUnlock() if info, exists := cm.clients[cluster]; exists { cm.incrementRef(info)