-rw-r--r-- | cgit.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -456,38 +456,38 @@ static void cgit_print_repo_page() static void cgit_fill_cache(struct cacheitem *item) { htmlfd = item->fd; item->st.st_mtime = time(NULL); 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; int fd = open(item->name, O_RDONLY); if (fd<0) die("Unable to open cached file %s", item->name); |