Skip to content

Commit 30e7388

Browse files
rfyiamcoolofekshenawandyakov
authored
fix: race slice for list function of ring client (#2931)
* fix: race slice for list of ring client Signed-off-by: rfyiamcool <[email protected]> * fix: copy wrong list Co-authored-by: Nedyalko Dyakov <[email protected]> --------- Signed-off-by: rfyiamcool <[email protected]> Co-authored-by: ofekshenawa <[email protected]> Co-authored-by: Nedyalko Dyakov <[email protected]>
1 parent 37accb4 commit 30e7388

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ring.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ func (c *ringSharding) List() []*ringShard {
341341

342342
c.mu.RLock()
343343
if !c.closed {
344-
list = c.shards.list
344+
list = make([]*ringShard, len(c.shards.list))
345+
copy(list, c.shards.list)
345346
}
346347
c.mu.RUnlock()
347348

0 commit comments

Comments
 (0)