mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 00:24:40 +01:00
cache of events improvement
don't reset/recalculate checksums on every configuration change, only if the checksums config item has changed.
This commit is contained in:
parent
431e2d3ed9
commit
0207e3a55f
1 changed files with 7 additions and 0 deletions
|
@ -107,6 +107,7 @@ func (e *EventsStore) ReplaceItem(oldProc, newProc *Process) {
|
|||
// Note: in rare occasions, the process being replaced is the older one.
|
||||
// if oldProc.Starttime > newProc.Starttime {}
|
||||
//
|
||||
|
||||
newProc.PPID = oldProc.ID
|
||||
e.UpdateItem(newProc)
|
||||
|
||||
|
@ -307,14 +308,20 @@ func (e *EventsStore) SetComputeChecksums(compute bool) {
|
|||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
|
||||
if compute == e.checksumsEnabled {
|
||||
log.Debug("SetComputeChecksums(), no changes (%v, %v)", e.checksumsEnabled, compute)
|
||||
return
|
||||
}
|
||||
e.checksumsEnabled = compute
|
||||
if !compute {
|
||||
log.Debug("SetComputeChecksums() disabled, deleting saved checksums")
|
||||
for _, item := range e.eventByPID {
|
||||
// XXX: reset saved checksums? or keep them in cache?
|
||||
item.Proc.ResetChecksums()
|
||||
}
|
||||
return
|
||||
}
|
||||
log.Debug("SetComputeChecksums() enabled, recomputing cached checksums")
|
||||
for _, item := range e.eventByPID {
|
||||
if item.Proc.ChecksumsCount() == 0 {
|
||||
item.Proc.ComputeChecksums(e.checksums)
|
||||
|
|
Loading…
Add table
Reference in a new issue