Squashed commit of the following:
commit
544acc5afc312a7aea9c35d726171e52c2edc2d2
Author: Steve Chew <stechew@cisco.com>
Date: Thu Sep 12 21:50:36 2019 -0400
flow: When walking uni_list stop before reaching head.
while ( (uni_list->get_count() > max_uni) && flow && (pruned < cleanup_flows) )
{
Flow* prune_me = flow;
- flow = prune_me->prev;
+ flow = uni_list->get_prev(prune_me);
if ( prune_me->was_blocked() )
continue;
{
head = new snort::Flow;
tail = new snort::Flow;
-
head->next = tail;
tail->prev = head;
+ head->prev = nullptr;
+ tail->next = nullptr;
}
~FlowUniList()
void link_uni(snort::Flow* flow)
{
-
flow->next = head->next;
flow->prev = head;
-
head->next->prev = flow;
head->next = flow;
-
++count;
}
if ( !flow->next )
return;
- --count;
-
flow->next->prev = flow->prev;
flow->prev->next = flow->next;
-
flow->next = flow->prev = nullptr;
+ --count;
+
}
snort::Flow* get_oldest_uni()
- { return tail->prev; }
+ {
+ return ( tail->prev != head ) ? tail->prev : nullptr;
+ }
+
+ snort::Flow* get_prev(snort::Flow* flow)
+ {
+ return ( flow->prev != head ) ? flow->prev : nullptr;
+ }
unsigned get_count() const
{ return count; }