Skip to content

Commit

Permalink
fix: Obtain write lock while reloading index (#1659)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Haines <haines@cerbos.dev>
  • Loading branch information
haines committed Jun 22, 2023
1 parent c1cfadc commit ad6928b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/storage/index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ func (idx *index) Reload(ctx context.Context) ([]storage.Event, error) {
return nil, err
}

idx.mu.RLock()
defer idx.mu.RUnlock()
idx.mu.Lock()
defer idx.mu.Unlock()
idx.fileToModID = newIdx.fileToModID
idx.executables = newIdx.executables
idx.dependents = newIdx.dependents
Expand Down

0 comments on commit ad6928b

Please sign in to comment.