mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 22:14:53 +00:00
Squash a leak in LRU caches
This commit is contained in:
parent
3b56c58f00
commit
51da4856e2
4 changed files with 14 additions and 7 deletions
2
env.cpp
2
env.cpp
|
@ -1005,7 +1005,7 @@ static int try_remove( env_node_t *n,
|
||||||
has_changed = 1;
|
has_changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
n->env.erase(result);
|
n->env.erase(result);
|
||||||
delete v;
|
delete v;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,6 +625,8 @@ void history_t::save_internal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure we clear all nodes, since this doesn't happen automatically */
|
||||||
|
lru.evict_all_nodes();
|
||||||
|
|
||||||
if( fclose( out ) || !ok )
|
if( fclose( out ) || !ok )
|
||||||
{
|
{
|
||||||
|
|
10
iothread.cpp
10
iothread.cpp
|
@ -142,7 +142,7 @@ int iothread_perform_base(int (*handler)(void *), void (*completionCallback)(voi
|
||||||
iothread_init();
|
iothread_init();
|
||||||
|
|
||||||
/* Create and initialize a request. */
|
/* Create and initialize a request. */
|
||||||
struct ThreadedRequest_t *req = (struct ThreadedRequest_t *)malloc(sizeof *req);
|
struct ThreadedRequest_t *req = new ThreadedRequest_t();
|
||||||
req->next = NULL;
|
req->next = NULL;
|
||||||
req->handler = handler;
|
req->handler = handler;
|
||||||
req->completionCallback = completionCallback;
|
req->completionCallback = completionCallback;
|
||||||
|
@ -186,9 +186,11 @@ void iothread_service_completion(void) {
|
||||||
s_active_thread_count -= 1;
|
s_active_thread_count -= 1;
|
||||||
|
|
||||||
/* Handle the request */
|
/* Handle the request */
|
||||||
if (req && req->completionCallback) {
|
if (req) {
|
||||||
req->completionCallback(req->context, req->handlerResult);
|
if (req->completionCallback)
|
||||||
}
|
req->completionCallback(req->context, req->handlerResult);
|
||||||
|
delete req;
|
||||||
|
}
|
||||||
|
|
||||||
/* Maybe spawn another thread, if there's more work to be done. */
|
/* Maybe spawn another thread, if there's more work to be done. */
|
||||||
VOMIT_ON_FAILURE(pthread_mutex_lock(&s_request_queue_lock));
|
VOMIT_ON_FAILURE(pthread_mutex_lock(&s_request_queue_lock));
|
||||||
|
|
3
lru.h
3
lru.h
|
@ -101,6 +101,9 @@ class lru_cache_t {
|
||||||
mouth.prev = mouth.next = &mouth;
|
mouth.prev = mouth.next = &mouth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Note that we do not define a destructor. We cannot evict all nodes (even though they typically need to be deleted by their creator). */
|
||||||
|
|
||||||
|
|
||||||
/** Returns the node for a given key, or NULL */
|
/** Returns the node for a given key, or NULL */
|
||||||
node_type_t *get_node(const wcstring &key) {
|
node_type_t *get_node(const wcstring &key) {
|
||||||
node_type_t *result = NULL;
|
node_type_t *result = NULL;
|
||||||
|
|
Loading…
Reference in a new issue