fix data-race warnings (#4036)

* fix data-race warnings

* update utils pkg

* utils update

* update utils

* bumping utils

---------

Co-authored-by: mzack <marco.rivoli.nvh@gmail.com>
Co-authored-by: Sandeep Singh <sandeep@projectdiscovery.io>
This commit is contained in:
Ramana Reddy 2023-09-04 12:59:24 +05:30 committed by GitHub
parent a12ef5c11c
commit 5bd4e68771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()
}
}
})