From b919e8114d258dead6642d09d126d4599268ede3 Mon Sep 17 00:00:00 2001 From: Roi Vazquez Date: Wed, 26 Jul 2023 15:05:29 +0200 Subject: [PATCH] Use safe functions to set alias and avoid concurrent writes to a sahred object --- pkg/redis/server/pool.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/redis/server/pool.go b/pkg/redis/server/pool.go index 17d5f8e1..56521f5c 100644 --- a/pkg/redis/server/pool.go +++ b/pkg/redis/server/pool.go @@ -8,7 +8,7 @@ import ( "github.com/go-redis/redis/v8" ) -// SentinelPool holds a thread safe list of Servers. +// ServerPool holds a thread safe list of Servers. // It is intended for client reuse throughout the code. type ServerPool struct { servers []*Server @@ -42,8 +42,8 @@ func (pool *ServerPool) GetServer(connectionString string, alias *string) (*Serv } if srv = pool.indexByHostPort()[opts.Addr]; srv != nil { // set the alias if it has been passed down - if alias != nil { - srv.alias = *alias + if alias != nil && srv.GetAlias() != *alias { + srv.SetAlias(*alias) } return srv, nil }