summaryrefslogtreecommitdiff
path: root/internal/event
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-10 22:34:17 +0200
committerPaul Buetow <paul@buetow.org>2026-03-10 22:34:17 +0200
commit80d8993dca4cf7945c492406489fb9d966e2dc44 (patch)
tree51bb8eda2a60c17cf04294370d095b6f86d0f035 /internal/event
parentd1aeb4afa9afee8a0cce8827b4c2dd9f8c01fe5b (diff)
eventloop: bound pending enter and proc-fd caches (task 425)
Diffstat (limited to 'internal/event')
-rw-r--r--internal/event/pair.go10
-rw-r--r--internal/event/pair_test.go10
2 files changed, 18 insertions, 2 deletions
diff --git a/internal/event/pair.go b/internal/event/pair.go
index 131c6b3..3eb8a16 100644
--- a/internal/event/pair.go
+++ b/internal/event/pair.go
@@ -120,8 +120,14 @@ func (e *Pair) Dump() string {
}
func (e *Pair) Recycle() {
- e.EnterEv.Recycle()
- e.ExitEv.Recycle()
+ if e.EnterEv != nil {
+ e.EnterEv.Recycle()
+ }
+ if e.ExitEv != nil {
+ e.ExitEv.Recycle()
+ }
+ e.EnterEv = nil
+ e.ExitEv = nil
e.File = nil
e.Comm = ""
e.Duration = 0
diff --git a/internal/event/pair_test.go b/internal/event/pair_test.go
index 43e9945..eb033dc 100644
--- a/internal/event/pair_test.go
+++ b/internal/event/pair_test.go
@@ -55,3 +55,13 @@ func TestPairCalculateDurationsWithPreviousExit(t *testing.T) {
t.Fatalf("DurationToPrev = %d, want 500", pair.DurationToPrev)
}
}
+
+func TestPairRecycleHandlesMissingExitEvent(t *testing.T) {
+ pair := NewPair(&types.OpenEvent{
+ Time: 1000,
+ Pid: 1,
+ Tid: 2,
+ })
+
+ pair.Recycle()
+}