From a488187a2265809d276454a87e3f17fd2adc552e Mon Sep 17 00:00:00 2001 From: Alexandre Rossi Date: Tue, 7 Nov 2023 14:46:45 +0100 Subject: [PATCH] properly init cache for purge_lru Purging the least recently used cache item relies on a linked list maintained during cache get and set. While uwsgi is running, this works well. But if the uwsgi process is stopped, lru_head and lru_tail are not initialized when loading the existing cache file. As a consequence, least recently used items never get deleted a full cache fails to set any new keys until the cache file is deleted. This patch properly initializes those variables. --- core/cache.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/cache.c b/core/cache.c index c3bf7d6e3..6e9b26149 100644 --- a/core/cache.c +++ b/core/cache.c @@ -737,6 +737,12 @@ void uwsgi_cache_fix(struct uwsgi_cache *uc) { if (uci->expires && (!next_scan || next_scan > uci->expires)) { next_scan = uci->expires; } + if (!uc->lru_head && !uci->lru_prev) { + uc->lru_head = i; + } + if (!uc->lru_tail && !uci->lru_next) { + uc->lru_tail = i; + } restored++; } else {