Skip to content

Commit

Permalink
rule: Ensure rule matcher is locked before updating (#159)
Browse files Browse the repository at this point in the history
Lock CachedMatcher before rules are updated when HTTPMatcher refreshes to avoid concurrent map iteration and map write errors.

Signed-off-by: Julian Tescher <jatescher@gmail.com>
  • Loading branch information
jtescher authored and aeneasr committed Apr 3, 2019
1 parent 43e500d commit 6fb7151
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rule/matcher_cached_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func (m *HTTPMatcher) Refresh() error {
return errors.Errorf("unable to fetch rules from backend, got status code %d but expected %d", response.StatusCode, http.StatusOK)
}

m.Lock()
defer m.Unlock()
inserted := map[string]bool{}
for _, r := range rules {
if len(r.Match.Methods) == 0 {
Expand Down

0 comments on commit 6fb7151

Please sign in to comment.