Make ReqInfo concurrency safe (#15204)

Some read/writes of ReqInfo did not get appropriate locks, leading to races.

Make sure reading and writing holds appropriate locks.
This commit is contained in:
Klaus Post
2022-06-30 10:48:50 -07:00
committed by GitHub
parent 8856a2d77b
commit 9004d69c6f
5 changed files with 11 additions and 6 deletions

View File

@@ -792,6 +792,8 @@ func likelyUnescapeGeneric(p string, escapeFn func(string) (string, error)) stri
func updateReqContext(ctx context.Context, objects ...ObjectV) context.Context {
req := logger.GetReqInfo(ctx)
if req != nil {
req.Lock()
defer req.Unlock()
req.Objects = make([]logger.ObjectVersion, 0, len(objects))
for _, ov := range objects {
req.Objects = append(req.Objects, logger.ObjectVersion{