Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tetragon: Update eventcache on New() call and cleanup old state #282

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/eventcache/eventcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type cacheObj struct {

type Cache struct {
objsChan chan cacheObj
done chan bool
cache []cacheObj
server *server.Server
dur time.Duration
Expand Down Expand Up @@ -141,6 +142,9 @@ func (ec *Cache) loop() {
case event := <-ec.objsChan:
eventcachemetrics.EventCacheCount.Inc()
ec.cache = append(ec.cache, event)

case <-ec.done:
return
}
}
}
Expand Down Expand Up @@ -181,11 +185,12 @@ func (ec *Cache) Add(internal *process.ProcessInternal,

func NewWithTimer(s *server.Server, dur time.Duration) *Cache {
if cache != nil {
return cache
cache.done <- true
}

cache = &Cache{
objsChan: make(chan cacheObj),
done: make(chan bool),
cache: make([]cacheObj, 0),
server: s,
dur: dur,
Expand Down