Skip to content

Commit

Permalink
bug: fix data race in hclogger (#4645)
Browse files Browse the repository at this point in the history
* bug: fix data race in hclogger
  • Loading branch information
irenarindos authored Apr 17, 2024
1 parent 608b6bb commit 0160258
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 0160258

Please sign in to comment.