Skip to content

Commit

Permalink
fix: process_execute_failed use correct lru
Browse files Browse the repository at this point in the history
- use the correct LRU (base events)
- remove unused LRU
  • Loading branch information
OriGlassman authored and geyslan committed Sep 9, 2024
1 parent 312a122 commit 5ba9087
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions pkg/events/derive/process_execute_failed.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import (

// ExecFailedGenerator is the object which implement the ProcessExecuteFailed event derivation
type ExecFailedGenerator struct {
execEndInfo *lru.Cache[int, execEndInfo]
baseEvents *lru.Cache[int, *trace.Event]
deriveBase deriveBase
baseEvents *lru.Cache[int, *trace.Event]
deriveBase deriveBase
}

// InitProcessExecuteFailedGenerator initialize a new generator for the ProcessExecuteFailed event.
Expand All @@ -23,18 +22,13 @@ func InitProcessExecuteFailedGenerator() (*ExecFailedGenerator, error) {
// For now, we assume that the current value is sufficient
const executionEventsCacheSize = 16

executeProcsCache, err := lru.New[int, execEndInfo](executionEventsCacheSize)
if err != nil {
return nil, err
}
executeParamsCache, err := lru.New[int, *trace.Event](executionEventsCacheSize)
if err != nil {
return nil, err
}
return &ExecFailedGenerator{
execEndInfo: executeProcsCache,
baseEvents: executeParamsCache,
deriveBase: makeDeriveBase(events.ProcessExecuteFailed),
baseEvents: executeParamsCache,
deriveBase: makeDeriveBase(events.ProcessExecuteFailed),
}, nil
}

Expand Down Expand Up @@ -78,7 +72,7 @@ func (gen *ExecFailedGenerator) deriveEvent(event *trace.Event) (
// handleExecFinished will add info on top of base event unless events came out of order. Sends an event in any case.
// Should be simplified once events reach from kernel-space to user-space are ordered!
func (gen *ExecFailedGenerator) handleExecFinished(event *trace.Event) (*trace.Event, error) {
defer gen.execEndInfo.Remove(event.HostProcessID)
defer gen.baseEvents.Remove(event.HostProcessID)
execInfo := execEndInfo{
returnCode: event.ReturnValue,
timestamp: event.Timestamp,
Expand Down

0 comments on commit 5ba9087

Please sign in to comment.