Skip to content

Commit

Permalink
use RW lock
Browse files Browse the repository at this point in the history
  • Loading branch information
korotkov-aerospike committed Nov 4, 2024
1 parent b287218 commit 2a7162e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/service/client_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2a7162e

Please sign in to comment.