Manager: fix race condition in logging of worker properties
Dereferencing the `w *persistence.Worker` pointer should happen directly in the function call, not in the zerolog callback function.
This commit is contained in:
parent
bb1acef054
commit
79bac3a5f3
@ -65,12 +65,16 @@ func requestWorkerStore(e echo.Context, w *persistence.Worker) {
|
||||
req := e.Request()
|
||||
reqCtx := context.WithValue(req.Context(), workerKey, w)
|
||||
|
||||
// Take copies now to avoid race conditions later.
|
||||
wUUID := w.UUID
|
||||
wName := w.Name
|
||||
|
||||
// Update the logger in this context to reflect the Worker.
|
||||
l := zerolog.Ctx(reqCtx)
|
||||
l.UpdateContext(func(c zerolog.Context) zerolog.Context {
|
||||
return c.
|
||||
Str("wUUID", w.UUID).
|
||||
Str("wName", w.Name)
|
||||
Str("wUUID", wUUID).
|
||||
Str("wName", wName)
|
||||
})
|
||||
|
||||
e.SetRequest(req.WithContext(reqCtx))
|
||||
|
Loading…
x
Reference in New Issue
Block a user