Don't time out processes in a cumulative view (fixes #39)

This commit is contained in:
Arnout Engelen
2016-04-14 20:00:30 +02:00
parent 8b245e1be0
commit 3facf4f34b
3 changed files with 59 additions and 67 deletions

View File

@@ -346,3 +346,29 @@ void procclean() {
// delete conninode;
prg_cache_clear();
}
void remove_timed_out_processes() {
ProcList *previousproc = NULL;
for (ProcList *curproc = processes; curproc != NULL; curproc = curproc->next) {
if ((curproc->getVal()->getLastPacket() + PROCESSTIMEOUT <=
curtime.tv_sec) &&
(curproc->getVal() != unknowntcp) &&
(curproc->getVal() != unknownudp) && (curproc->getVal() != unknownip)) {
if (DEBUG)
std::cout << "PROC: Deleting process\n";
ProcList *todelete = curproc;
Process *p_todelete = curproc->getVal();
if (previousproc) {
previousproc->next = curproc->next;
curproc = curproc->next;
} else {
processes = curproc->getNext();
curproc = processes;
}
delete todelete;
delete p_todelete;
}
previousproc = curproc;
}
}