Skip to content

Commit

Permalink
fix(race-condition): pass response as goroutine param
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweak committed Oct 29, 2024
1 parent acfce68 commit d86c93a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,24 +350,24 @@ func (s *SouinBaseHandler) Store(
}
for _, storer := range s.Storers {
wg.Add(1)
go func(currentStorer types.Storer) {
go func(currentStorer types.Storer, currentRes http.Response) {
defer wg.Done()
if currentStorer.SetMultiLevel(
cachedKey,
variedKey,
response,
vhs,
res.Header.Get("Etag"), ma,
currentRes.Header.Get("Etag"), ma,
variedKey,
) == nil {
s.Configuration.GetLogger().Debugf("Stored the key %s in the %s provider", variedKey, currentStorer.Name())
res.Request = rq
currentRes.Request = rq
} else {
mu.Lock()
fails = append(fails, fmt.Sprintf("; detail=%s-INSERTION-ERROR", currentStorer.Name()))
mu.Unlock()
}
}(storer)
}(storer, res)
}

wg.Wait()
Expand Down

0 comments on commit d86c93a

Please sign in to comment.