Skip to content

Commit aa1c021

Browse files
committed
++ cache
1 parent 12d8dc1 commit aa1c021

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

storage/cache.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,13 @@ int NHTFlowCache::put_pkt(Packet &pkt)
429429
CacheRowSpan row_span(&m_flow_table[row_begin], m_line_size);
430430

431431
prefetch_export_expired();
432-
433-
if (flow_found) {
434432
#ifdef WITH_CTT
435-
const bool flow_is_waiting_for_export = try_to_export_delayed_flow(pkt, flow_index.value() + row_begin);
433+
const bool flow_is_waiting_for_export = flow_found && try_to_export_delayed_flow(pkt, flow_index.value() + row_begin);
436434
#else
437-
constexpr bool flow_is_waiting_for_export = false;
435+
constexpr bool flow_is_waiting_for_export = false;
438436
#endif /* WITH_CTT */
437+
438+
if (flow_found && !m_flow_table[flow_index.value() + row_begin]->is_empty()) {
439439
/* Existing flow record was found, put flow record at the first index of flow line. */
440440
m_cache_stats.lookups += flow_index.value() + 1;
441441
m_cache_stats.lookups2 += (flow_index.value() + 1) * (flow_index.value() + 1);
@@ -446,7 +446,9 @@ int NHTFlowCache::put_pkt(Packet &pkt)
446446
return process_flow(pkt, flow_index.value(), flow_is_waiting_for_export);
447447
}
448448
/* Existing flow record was not found. Find free place in flow line. */
449-
const std::optional<size_t> empty_index = row_span.find_empty();
449+
const std::optional<size_t> empty_index = flow_found && m_flow_table[flow_index.value() + row_begin]->is_empty()
450+
? flow_index.value()
451+
: row_span.find_empty();
450452
const bool empty_found = empty_index.has_value();
451453
if (empty_found) {
452454
flow_index = empty_index.value() + row_begin;

0 commit comments

Comments
 (0)