Skip to content

Commit

Permalink
fix datarace when reading handlers in SharedHandler
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Lamarre <alexandre.lamarre@suse.com>
  • Loading branch information
alexandreLamarre committed Jul 31, 2024
1 parent 1feca24 commit 622f79c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/controller/sharedhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ func (h *SharedHandler) OnChange(key string, obj runtime.Object) error {
var (
errs errorList
)
handlers := make([]handlerEntry, len(h.handlers))
h.lock.RLock()
handlers := h.handlers
for i, x := range h.handlers {
handlers[i] = x
}
h.lock.RUnlock()

for _, handler := range handlers {
Expand Down

0 comments on commit 622f79c

Please sign in to comment.