List for cgit developers and users
 help / color / mirror / Atom feed
* premature exits bork cache
@ 2016-02-26 12:29 Jason
  2016-02-26 16:09 ` john
  0 siblings, 1 reply; 3+ messages in thread
From: Jason @ 2016-02-26 12:29 UTC (permalink / raw)


Hi guys,

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:

https://git.zx2c4.com/cgit/commit/?id=e9cbdf64632fbe64d6b0c4974ac947ef954938e7

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:

https://git.zx2c4.com/cgit/tree/ui-shared.c#n695

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?

Jason


^ permalink raw reply	[flat|nested] 3+ messages in thread

* premature exits bork cache
  2016-02-26 12:29 premature exits bork cache Jason
@ 2016-02-26 16:09 ` john
  2016-02-26 16:18   ` Jason
  0 siblings, 1 reply; 3+ messages in thread
From: john @ 2016-02-26 16:09 UTC (permalink / raw)


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:
> 
> https://git.zx2c4.com/cgit/commit/?id=e9cbdf64632fbe64d6b0c4974ac947ef954938e7
> 
> 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:
> 
> https://git.zx2c4.com/cgit/tree/ui-shared.c#n695
> 
> 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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* premature exits bork cache
  2016-02-26 16:09 ` john
@ 2016-02-26 16:18   ` Jason
  0 siblings, 0 replies; 3+ messages in thread
From: Jason @ 2016-02-26 16:18 UTC (permalink / raw)


Ahh, good point.

There are a couple more calls to exit that I'm investigating. This is
certainly not the nicest way to handle things...


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-26 16:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-26 12:29 premature exits bork cache Jason
2016-02-26 16:09 ` john
2016-02-26 16:18   ` Jason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).