Don't evict autoloaded functions from background threads

Fixes a bug where generating a lot of autoloaded functions from
syntax highlighting would result in evicting nodes on background threads,
resulting in a thread error.

Fixes #1989
This commit is contained in:
ridiculousfish 2015-03-23 12:31:22 -07:00
parent 7aac3db55c
commit 01026c137f
2 changed files with 4 additions and 8 deletions

View file

@ -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;
}

8
lru.h
View file

@ -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;
}