Skip to content

Commit

Permalink
Access JSONGateResolverBuilder.resolvers under a lock (#463)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Robinson <hrobinson@slack-corp.com>
  • Loading branch information
henryr authored and dedelala committed Nov 12, 2024
1 parent de86aba commit 3c512f5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions go/vt/vtgateproxy/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,15 @@ func (b *JSONGateResolverBuilder) start() error {
}
parseCount.Add("changed", 1)

b.mu.RLock()
// notify all the resolvers that the targets changed
for _, r := range b.resolvers {
err = b.update(r)
if err != nil {
log.Errorf("Failed to update resolver: %v", err)
}
}
b.mu.RUnlock()
}
}()

Expand Down Expand Up @@ -422,7 +424,10 @@ func (b *JSONGateResolverBuilder) Build(target resolver.Target, cc resolver.Clie
if err != nil {
return nil, err
}

b.mu.Lock()
b.resolvers = append(b.resolvers, r)
b.mu.Unlock()

return r, nil
}
Expand Down

0 comments on commit 3c512f5

Please sign in to comment.