Re: [PATCH] http-backend: Don't infinite loop during die()
- From
Shawn Pearce <spearce@spearce.org>
- Date
- Mar 24, 2010, 20:25 UTC
- Message-ID
- <ec874dac1003241325y43fdec78gfbb3d115e1aaa1b0@mail.gmail.com>
- In-Reply-To
- <alpine.LFD.2.00.1003241623370.694@xanadu.home>
On Wed, Mar 24, 2010 at 1:24 PM, Nicolas Pitre <nico@fluxnic.net> wrote:
Show 23 quoted lines
> On Wed, 24 Mar 2010, Shawn O. Pearce wrote: > >> Junio C Hamano <gitster@pobox.com> wrote: >> > "Shawn O. Pearce" <spearce@spearce.org> writes: >> > >> > > If stdout has already been closed by the CGI and die() gets called, >> > > the CGI will fail to write the "Status: 500 Internal Server Error" to >> > > the pipe, which results in die() being called again (via safe_write). >> > > This goes on in an infinite loop until the stack overflows and the >> > > process is killed by SIGSEGV. >> > > >> > > Instead set a flag on the first die() invocation and perform no >> > > action during recursive die() calls. This way failures to write the >> > > error messages to the stdout pipe do not result in an infinite loop. >> > >> > Hmm. I would need something like this on top, but there must be a better >> > way. Ideas? >> >> Ick. >> >> Just exit(0) if dead is true. > > Do you really want the exit code to be 0 if you're dying?
IIRC, yes. If we exit non-zero Apache really freaked out. That was a big part of my motivation to write the die_webcgi handler.
-- Shawn.