mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-27 20:25:12 +00:00
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:
parent
7aac3db55c
commit
01026c137f
2 changed files with 4 additions and 8 deletions
|
@ -64,7 +64,7 @@ void autoload_t::node_was_evicted(autoload_function_t *node)
|
||||||
ASSERT_IS_MAIN_THREAD();
|
ASSERT_IS_MAIN_THREAD();
|
||||||
|
|
||||||
// Tell ourselves that the command was removed if it was loaded
|
// Tell ourselves that the command was removed if it was loaded
|
||||||
if (! node->is_loaded)
|
if (node->is_loaded)
|
||||||
this->command_removed(node->key);
|
this->command_removed(node->key);
|
||||||
delete node;
|
delete node;
|
||||||
}
|
}
|
||||||
|
|
8
lru.h
8
lru.h
|
@ -51,7 +51,7 @@ class lru_cache_t
|
||||||
{
|
{
|
||||||
private:
|
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;
|
const size_t max_node_count;
|
||||||
|
|
||||||
/** Count of nodes */
|
/** Count of nodes */
|
||||||
|
@ -192,13 +192,9 @@ public:
|
||||||
node->prev = &mouth;
|
node->prev = &mouth;
|
||||||
mouth.next = node;
|
mouth.next = node;
|
||||||
|
|
||||||
/* Update the count */
|
/* Update the count. This may push us over the maximum node count. */
|
||||||
node_count++;
|
node_count++;
|
||||||
|
|
||||||
/* Evict */
|
|
||||||
while (node_count > max_node_count)
|
|
||||||
evict_last_node();
|
|
||||||
|
|
||||||
/* Success */
|
/* Success */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue