From 75450307c0c5a0fdf9826e5b06bdf252cfe22df0 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 6 Sep 2026 20:14:48 -1000 Subject: Trim the comments and dead code across the tree --- source/cache.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'source/cache.c') diff --git a/source/cache.c b/source/cache.c index dd8ae7f..2d546bb 100644 --- a/source/cache.c +++ b/source/cache.c @@ -96,9 +96,8 @@ static int open_slot(struct cache_slot *slot) } /* - * A key longer than the buffer above can never be read back by open_slot, so - * a slot keyed on one would never match and every such request would - * regenerate its page while still writing a slot nothing can use. + * A key longer than the buffer above can never be read back by open_slot, + * so a slot keyed on one would be written but never match. */ static int key_fits_slot(const char *key) { @@ -238,10 +237,8 @@ static int lock_slot(struct cache_slot *slot) } // The lock landed on whatever inode the path named at open. A holder // finishing in between renames that inode into place as the live - // slot, so truncating it on the strength of the stale descriptor - // would tear down the page other requests are reading. Once the path - // is confirmed to still name this file the rename can no longer - // happen, because doing so takes the lock now held here. + // slot, and once the path is confirmed to still name this file that + // rename can no longer happen, because it takes the lock held here. if (fstat(slot->lock_fd, &held) || stat(slot->lock_path, &named) || held.st_ino != named.st_ino || held.st_dev != named.st_dev) { close(slot->lock_fd); @@ -291,10 +288,9 @@ void cache_abandon_fill(void) slot_being_filled = NULL; slot->abandoned = 1; - // The page is sitting in html.c's buffer and in stdio's, and both are - // emptied while stdout still points at the lock file, so the half - // rendered page goes into the file about to be removed rather than - // reaching the client ahead of whatever is written next. + // The page is sitting in html.c's buffer and in stdio's. Empty both + // while stdout still points at the lock file so the half rendered + // page never reaches the client. html_flush(); fflush(stdout); @@ -323,10 +319,9 @@ static int fill_slot(struct cache_slot *slot) slot->fn(); slot_being_filled = NULL; - // The page is sitting in html.c's buffer and then in stdio's, and all - // of it has to reach the lock file before that file is renamed into - // place. After an abandoned fill stdout is the client again and this - // same flush delivers the tail of the error page instead. + // All of the page has to reach the lock file before it is renamed + // into place. After an abandoned fill stdout is the client again and + // this same flush delivers the tail of the error page instead. html_flush(); if (fflush(stdout)) return errno; @@ -352,9 +347,7 @@ static void refresh_slot(struct cache_slot *slot) return; // If another process replaced the slot between open_slot and - // lock_slot, the copy already open is served rather than the newer - // one, which would mean opening that file and comparing the key in it, - // not worth a second descriptor and read on every expiry. + // lock_slot, the copy already open is served rather than the newer. if (is_modified(slot) || fill_slot(slot)) { unlock_slot(slot, 0); close_lock(slot); @@ -391,8 +384,7 @@ static int process_slot(struct cache_slot *slot) // A slot that opened cleanly but holds another key is a collision, // and two popular pages sharing one slot evict each other on every - // alternating visit. Nothing else makes that visible, because the - // cache keeps working and only quietly stops helping. + // alternating visit. if (!err) log_error("[cgit] Cache slot %s holds a different key, " "consider a larger cache-size\n", slot->path); @@ -449,10 +441,8 @@ static char *format_time(const char *format, time_t when) } /* - * The accumulator is an unsigned long rather than a fixed 32 bit type, so on a - * 64 bit host this is not the published FNV-1 value. All that decides is which - * slot a key lands in, and nothing outside a single build has to agree on the - * answer. + * The accumulator is unsigned long, so on a 64 bit host this is not the + * published FNV-1 value. Only slot selection depends on it. */ unsigned long cache_hash_str(const char *str) { -- cgit v2.8.0