Skip to content

Commit

Permalink
Fix data race with hooks map
Browse files Browse the repository at this point in the history
Signed-off-by: AbdelrahmanElawady <abdoelawady125@gmail.com>
  • Loading branch information
AbdelrahmanElawady committed May 21, 2024
1 parent b643760 commit c1056d1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/hooks/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ func (m *Manager) Monitor(ctx context.Context, sync chan<- error) {
for {
select {
case event := <-watcher.Events:
m.lock.Lock()
m.hooks = make(map[string]*current.Hook)
for _, dir := range m.directories {
err = ReadDir(dir, m.extensionStages, m.hooks)
if err != nil {
logrus.Errorf("Failed loading hooks for %s: %v", event.Name, err)
}
}
m.lock.Unlock()
case <-ctx.Done():
err = ctx.Err()
logrus.Debugf("hook monitoring canceled: %v", err)
Expand Down

0 comments on commit c1056d1

Please sign in to comment.