Skip to content

Commit

Permalink
fix: race slice for list function of ring client (#2931)
Browse files Browse the repository at this point in the history
* fix: race slice for list of ring client

Signed-off-by: rfyiamcool <rfyiamcool@163.com>

* fix: copy wrong list

Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>

---------

Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
  • Loading branch information
3 people authored Feb 20, 2025
1 parent 37accb4 commit 30e7388
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ func (c *ringSharding) List() []*ringShard {

c.mu.RLock()
if !c.closed {
list = c.shards.list
list = make([]*ringShard, len(c.shards.list))
copy(list, c.shards.list)
}
c.mu.RUnlock()

Expand Down

0 comments on commit 30e7388

Please sign in to comment.