diff --git a/autoload.cpp b/autoload.cpp index 165afb39d..c883f8bf0 100644 --- a/autoload.cpp +++ b/autoload.cpp @@ -64,7 +64,7 @@ void autoload_t::node_was_evicted(autoload_function_t *node) ASSERT_IS_MAIN_THREAD(); // Tell ourselves that the command was removed if it was loaded - if (! node->is_loaded) + if (node->is_loaded) this->command_removed(node->key); delete node; } diff --git a/lru.h b/lru.h index e6418c68b..5899087c6 100644 --- a/lru.h +++ b/lru.h @@ -51,7 +51,7 @@ class lru_cache_t { private: - /** Max node count */ + /** Max node count. This may be (transiently) exceeded by add_node_without_eviction, which is used from background threads. */ const size_t max_node_count; /** Count of nodes */ @@ -192,13 +192,9 @@ public: node->prev = &mouth; mouth.next = node; - /* Update the count */ + /* Update the count. This may push us over the maximum node count. */ node_count++; - - /* Evict */ - while (node_count > max_node_count) - evict_last_node(); - + /* Success */ return true; }