From 131fc49186ce49a8632299f5e5bb9af164e2083c Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Mon, 21 Sep 2026 06:02:22 -1000 Subject: Log a cache slot that cannot be published --- source/cache.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/cache.c b/source/cache.c index 8123e5e..5c1c808 100644 --- a/source/cache.c +++ b/source/cache.c @@ -305,6 +305,17 @@ void cache_abandon_fill(void) unlink(slot->lock_path); } +// The page is served from the descriptor either way, so a failed rename only +// costs the next request a render. +static void publish_slot(struct cache_slot *slot) +{ + int err = unlock_slot(slot, 1); + + if (err) + log_error("[cgit] Unable to publish cache slot %s: %s (%d)\n", slot->path, + strerror(err), err); +} + /* * Renders with stdout pointed at the lock file, and on success or failure * alike it is unlock_slot that gives stdout back. @@ -363,7 +374,7 @@ static void refresh_slot(struct cache_slot *slot) close_lock(slot); } else { close_slot(slot); - unlock_slot(slot, 1); + publish_slot(slot); slot->cache_fd = slot->lock_fd; } } @@ -424,7 +435,7 @@ static int process_slot(struct cache_slot *slot) // concurrent writer put there for a different key, so what gets // printed is the descriptor still open on the lock file. slot->cache_fd = slot->lock_fd; - unlock_slot(slot, 1); + publish_slot(slot); err = serve_slot(slot); close_slot(slot); return err; @@ -546,6 +557,7 @@ int cache_ls(const char *path) slot.path = slot_path.buf; if ((err = open_slot(&slot)) != 0) { log_error("[cgit] Error opening %s: %s (%d)\n", slot_path.buf, strerror(err), err); + close_slot(&slot); continue; } // A truncated or corrupt slot may hold no NUL, so the print is -- cgit v2.8.0