From 5bd4e68771d5f94eaf1a70b20d9fa01ff63e44ef Mon Sep 17 00:00:00 2001 From: Ramana Reddy <90540245+RamanaReddy0M@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:59:24 +0530 Subject: [PATCH] fix data-race warnings (#4036) * fix data-race warnings * update utils pkg * utils update * update utils * bumping utils --------- Co-authored-by: mzack Co-authored-by: Sandeep Singh --- v2/pkg/protocols/common/executer/executer.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/v2/pkg/protocols/common/executer/executer.go b/v2/pkg/protocols/common/executer/executer.go index 81c286729..bfdf22421 100644 --- a/v2/pkg/protocols/common/executer/executer.go +++ b/v2/pkg/protocols/common/executer/executer.go @@ -3,6 +3,7 @@ package executer import ( "fmt" "strings" + "sync" "sync/atomic" "github.com/pkg/errors" @@ -71,6 +72,7 @@ func (e *Executer) Execute(input *contextargs.Context) (bool, error) { } previous := make(map[string]interface{}) + mtx := &sync.Mutex{} var lastMatcherEvent *output.InternalWrappedEvent writeFailureCallback := func(event *output.InternalWrappedEvent, matcherStatus bool) { if !results.Load() && matcherStatus { @@ -105,7 +107,9 @@ func (e *Executer) Execute(input *contextargs.Context) (bool, error) { // in that case we can skip it, otherwise we've to show failure in // case of matcher-status flag. if !event.HasOperatorResult() && !event.UsesInteractsh { + mtx.Lock() lastMatcherEvent = event + mtx.Unlock() } else { if !(event.UsesInteractsh && event.InteractshMatched.Load()) && writer.WriteResult(event, e.options.Output, e.options.Progress, e.options.IssuesClient) { if event.UsesInteractsh { @@ -113,7 +117,9 @@ func (e *Executer) Execute(input *contextargs.Context) (bool, error) { } results.Store(true) } else { + mtx.Lock() lastMatcherEvent = event + mtx.Unlock() } } })