Add GetOrFindPrimaryProcess to correctly group process/threads

This commit is contained in:
Daniel
2019-04-26 15:17:44 +02:00
parent 78a0b3c1fb
commit 6495b4fe5f
4 changed files with 77 additions and 21 deletions

View File

@@ -94,13 +94,27 @@ func CleanProcessStorage(thresholdDuration time.Duration) {
defer processesLock.Unlock()
threshold := time.Now().Add(-thresholdDuration).Unix()
// clean primary processes
for _, p := range processes {
p.Lock()
if p.FirstCommEstablished < threshold && p.CommCount == 0 {
if !p.Virtual && p.LastCommEstablished < threshold && p.CommCount == 0 {
go p.Delete()
}
p.Unlock()
}
// clean virtual processes
for _, p := range processes {
p.Lock()
if p.Virtual {
_, parentIsAlive := processes[p.ParentPid]
if !parentIsAlive {
go p.Delete()
}
}
p.Unlock()
}
}
// SetDBController sets the database controller and allows the package to push database updates on a save. It must be set by the package that registers the "network" database.