mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
cache: fix data race in NotifyJoin (#1028)
In 35af5c0b91
, the check for multiple
cache servers in NotifyJoin is made to be done in a goroutine. That can
lead to a data race, because the memberlist can be changed at the time
the goroutine was run. go warns about this race when test memberlist was
run with "-race".
To fix this, we pass the nil check as argument to goroutine.
This commit is contained in:
parent
6ab797eb0b
commit
b90885b4c1
1 changed files with 3 additions and 3 deletions
6
cache/memberlist.go
vendored
6
cache/memberlist.go
vendored
|
@ -69,11 +69,11 @@ func (c *Cache) runMemberList(ctx context.Context) error {
|
|||
func (mh *memberlistHandler) NotifyJoin(node *memberlist.Node) {
|
||||
mh.log.Debug().Interface("node", node).Msg("node joined")
|
||||
|
||||
go func() {
|
||||
if mh.memberlist != nil && mh.memberlist.NumMembers() > 1 {
|
||||
go func(memberListNotNil bool) {
|
||||
if memberListNotNil && mh.memberlist.NumMembers() > 1 {
|
||||
mh.log.Error().Msg("detected multiple cache servers, which is not supported")
|
||||
}
|
||||
}()
|
||||
}(mh.memberlist != nil)
|
||||
}
|
||||
|
||||
func (mh *memberlistHandler) NotifyLeave(node *memberlist.Node) {
|
||||
|
|
Loading…
Add table
Reference in a new issue