diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Keep error pages out of the cache
Diffstat (limited to 'source')
| -rw-r--r-- | source/cgit.c | 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-shared.c | 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 files changed, 8 insertions, 3 deletions
diff --git a/source/cgit.c b/source/cgit.c index ac8922b..12981c2 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -82,9 +82,8 @@ static void isolate_git_environment(void) */ static NORETURN void die_routine(const char *msg, va_list params) { - // A page is rendered with stdout pointed at the cache file, so the - // message would otherwise be written there instead of to the visitor. - cache_abandon_fill(); + // The error page abandons any cache fill in progress, so the message + // reaches the visitor rather than the cache file stdout points at. cgit_vprint_error_page(400, "Bad request", msg, params); exit(0); } diff --git a/source/ui-shared.c b/source/ui-shared.c index 066c25d..05fa30b 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -10,6 +10,7 @@ #define USE_THE_REPOSITORY_VARIABLE +#include "cache.h" #include "cgit.h" #include "html.h" #include "shared.h" @@ -1293,6 +1294,11 @@ void cgit_print_error_page(int code, const char *msg, const char *fmt, ...) void cgit_vprint_error_page(int code, const char *msg, const char *fmt, va_list ap) { + // An error page describes a condition that may not outlast the slot + // holding it. A request naming a commit not yet pushed would cache its + // 404 under the never-expiring static ttl and keep serving it after + // the push, so the error is rendered straight to the visitor instead. + cache_abandon_fill(); ctx.page.status = code; ctx.page.statusmsg = msg; cgit_print_layout_start(); |
