premature exits bork cache

John Keeping john at
Fri Feb 26 17:09:32 CET 2016

On Fri, Feb 26, 2016 at 01:29:21PM +0100, Jason A. Donenfeld wrote:
> When caching is turned on, if we exit(0) early from a cmd, the cache
> won't be properly finalized (or even sent), and we get a server error
> because of blank output. I just fixed this bug with redirect:
> This is fine, because it's called only from 1 function (three times),
> and that function then returns, so execution doesn't continue after
> the redirect. It simply gives control back to the caching layer that
> does things properly now.
> But I noticed we have this issue with HTTP HEAD method:
> Here we're calling exit(0). The motivation, I imagine, was that we
> want to retain the same handlers, but just return the headers for the
> HEAD method. Unfortunately, this borks the cache layer for the same
> reasons as described above. I'm not yet sure the cleanest way to fix
> this. Suggestions?

We set cfg.nocache in cgit.c for HEAD requests so I think we're already
okay in this case, although it is a subtle interaction.

More information about the CGit mailing list