Skip to content

Commit e1bede3

Browse files
committed
lock closing new shards in case ring was closed in the meantime
use the internal logger as it is used elsewhere Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
1 parent 3991bd2 commit e1bede3

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

ring.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"crypto/tls"
66
"errors"
77
"fmt"
8-
"log"
98
"net"
109
"strconv"
1110
"sync"
@@ -245,7 +244,7 @@ func (c *ringShards) SetAddrs(addrs map[string]string) {
245244
defer func() {
246245
err := shard.Client.Close()
247246
if err != nil {
248-
log.Printf("Failed to close ring shard client %s: %v", shard.addr, err)
247+
internal.Logger.Printf(context.Background(), "Failed to close ring shard client %s %s: %v", k, shard.addr, err)
249248
}
250249
}()
251250
}
@@ -266,14 +265,12 @@ func (c *ringShards) SetAddrs(addrs map[string]string) {
266265
if !c.closed {
267266
c.shards = shards
268267
c.list = list
269-
}
270-
c.mu.Unlock()
271-
272-
if c.closed {
268+
} else {
273269
for _, shard := range shards {
274270
shard.Client.Close()
275271
}
276272
}
273+
c.mu.Unlock()
277274

278275
c.rebalance()
279276
}

0 commit comments

Comments
 (0)