-rw-r--r-- | cgit.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -460,30 +460,30 @@ static void cgit_fill_cache(struct cacheitem *item) if (cgit_query_repo) cgit_print_repo_page(); else cgit_print_repolist(); } static void cgit_refresh_cache(struct cacheitem *item) { + cache_prepare(item); top: - if (!cache_lookup(item)) { - if (cache_lock(item)) { - cgit_fill_cache(item); - cache_unlock(item); - } else { + if (!cache_exist(item)) { + if (!cache_lock(item)) { sched_yield(); goto top; } - } else if (cache_expired(item)) { - if (cache_lock(item)) { + if (!cache_exist(item)) + cgit_fill_cache(item); + cache_unlock(item); + } else if (cache_expired(item) && cache_lock(item)) { + if (cache_expired(item)) cgit_fill_cache(item); cache_unlock(item); - } } } static void cgit_print_cache(struct cacheitem *item) { static char buf[4096]; ssize_t i; |