diff --git a/include/GenericHash.h b/include/GenericHash.h index e6ae896b13..f1fb1ce6bb 100644 --- a/include/GenericHash.h +++ b/include/GenericHash.h @@ -86,15 +86,6 @@ class GenericHash { */ inline u_int32_t getNumEntries() { return(current_size); }; - /** - * @brief Tell this GenericHash about a state transition of - * one of the entry it contains. GenericHash will use this - * information to count total state transitions. - * - * @param s The new state of the transition - */ - void notify_transition(HashEntryState s); - /** * @brief Add new entry to generic hash. * @details If current_size < max_hash_size, this method calculate a new hash key for the new entry, add it and update the current_size value. diff --git a/src/GenericHash.cpp b/src/GenericHash.cpp index cce03a62cb..799b028657 100644 --- a/src/GenericHash.cpp +++ b/src/GenericHash.cpp @@ -93,18 +93,6 @@ void GenericHash::cleanup() { /* ************************************ */ -void GenericHash::notify_transition(HashEntryState s) { - switch(s) { - case hash_entry_state_idle: - entry_state_transition_counters.num_idle_transitions++; - break; - default: - break; - } -} - -/* ************************************ */ - bool GenericHash::add(GenericHashEntry *h, bool do_lock) { if(hasEmptyRoom()) { u_int32_t hash = (h->key() % num_hashes); @@ -331,6 +319,7 @@ u_int GenericHash::purgeIdle(bool force_idle) { else prev->set_next(next); + entry_state_transition_counters.num_idle_transitions++; num_idled++, current_size--; head = next; continue; @@ -376,7 +365,7 @@ void GenericHash::lua(lua_State *vm) { delta = entry_state_transition_counters.num_idle_transitions - entry_state_transition_counters.num_purged; if(delta < 0) - ntop->getTrace()->traceEvent(TRACE_ERROR, "Internal error: unexpected number of entries in state [iface: %s][%s][hash_entry_state_idle: %i]", iface ? iface->get_name(): "", name, delta); + ntop->getTrace()->traceEvent(TRACE_ERROR, "Internal error: unexpected number of entries in state [iface: %s][%s][hash_entry_state_idle: %i][num_idle_transitions: %u][num_purged: %u]", iface ? iface->get_name(): "", name, delta, entry_state_transition_counters.num_idle_transitions, entry_state_transition_counters.num_purged); else lua_push_uint64_table_entry(vm, "hash_entry_state_idle", (u_int64_t)delta); diff --git a/src/GenericHashEntry.cpp b/src/GenericHashEntry.cpp index 9d52a6651c..3138c59ba3 100644 --- a/src/GenericHashEntry.cpp +++ b/src/GenericHashEntry.cpp @@ -68,12 +68,8 @@ void GenericHashEntry::set_state(HashEntryState s) { && (!iface || iface->isRunning())) ntop->getTrace()->traceEvent(TRACE_ERROR, "Internal error: invalid state transition %d -> %d", hash_entry_state, s); - else { + else hash_entry_state = s; - - if(hash_table) - hash_table->notify_transition(s); - } }; /* ***************************************** */