diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Keep clone files and oversized responses out of the cache
The dumb transport reads files that already sit on the disk, so a pack copied into a slot cost that disk twice and the request a second write of every byte. A snapshot took a slot whatever its size, so a visitor naming distinct refs and ids could fill the cache root with archives. `cache-max-slot-size`, 64 MB unless set, now serves a larger response from the lock file and drops it, along with any expired copy it would have replaced.
Diffstat (limited to '')
-rw-r--r--source/cache.h8
1 file changed, 6 insertions, 2 deletions
diff --git a/source/cache.h b/source/cache.h
index bae283c..d3a7ec4 100644
--- a/source/cache.h
+++ b/source/cache.h
@@ -7,6 +7,8 @@
#ifndef CGIT_CACHE_H
#define CGIT_CACHE_H
+#include <stddef.h>
+
typedef void (*cache_fill_fn)(void);
/*
@@ -14,10 +16,12 @@ typedef void (*cache_fill_fn)(void);
* slot for that key is there and rendering it through fn when it is not. size
* is how many slots the cache may use and path is the directory holding them.
* ttl is how many minutes a slot for this key stays fresh, where a negative
- * ttl never expires and a ttl of zero skips the cache for this request.
+ * ttl never expires and a ttl of zero skips the cache for this request. A
+ * page larger than max_bytes is served but not kept, and zero sets no bound.
* Returns 0 when the page was written, and an errno value when it was not.
*/
-extern int cache_process(int size, const char *path, const char *key, int ttl, cache_fill_fn fn);
+extern int cache_process(int size, const char *path, const char *key, int ttl,
+ size_t max_bytes, cache_fill_fn fn);
/*
* Write one line per cache slot to stdout, giving its path, modification time,