File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ type Engine struct {
5959 psnap ps.Snapshotter
6060
6161 matches []* ruleMatch
62+ mmu sync.Mutex // guards the rule matches slice
6263 sequences []* sequenceState
6364
6465 scavenger * time.Ticker
@@ -306,6 +307,8 @@ func (e *Engine) ProcessEvent(evt *kevent.Kevent) (bool, error) {
306307// defined in the rule definition.
307308func (e * Engine ) processActions () error {
308309 defer e .clearMatches ()
310+ e .mmu .Lock ()
311+ defer e .mmu .Unlock ()
309312 for _ , m := range e .matches {
310313 f , evts := m .ctx .Filter , m .ctx .Events
311314 filterMatches .Add (f .Name , 1 )
@@ -344,12 +347,16 @@ func (e *Engine) appendMatch(f *config.FilterConfig, evts ...*kevent.Kevent) {
344347 Events : evts ,
345348 Filter : f ,
346349 }
350+ e .mmu .Lock ()
351+ defer e .mmu .Unlock ()
347352 e .matches = append (e .matches , & ruleMatch {ctx : ctx })
348353 if e .matchFunc != nil {
349354 e .matchFunc (f , evts ... )
350355 }
351356}
352357
353358func (e * Engine ) clearMatches () {
359+ e .mmu .Lock ()
360+ defer e .mmu .Unlock ()
354361 e .matches = make ([]* ruleMatch , 0 )
355362}
You can’t perform that action at this time.
0 commit comments