Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of bug: fix data race in hclogger into release/0.16.x #4657

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion internal/event/hclog_formatter_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ type hclogFormatterFilter struct {
allow []*filter
deny []*filter
signer signer
l sync.RWMutex
// l protects the signer field
l sync.RWMutex
}

func newHclogFormatterFilter(jsonFormat bool, opt ...Option) (*hclogFormatterFilter, error) {
Expand Down Expand Up @@ -205,6 +206,8 @@ func (f *hclogFormatterFilter) Process(ctx context.Context, e *eventlogger.Event
if err != nil {
return nil, fmt.Errorf("%s: unable to format: %w", op, err)
}
f.l.Lock()
defer f.l.Unlock()
if f.signer != nil && string(e.Type) == string(AuditType) {
bufHmac, err := f.signer(ctx, buf.Bytes())
if err != nil {
Expand Down
Loading