Re: Funny error with git gc...
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- May 24, 2009, 17:37 UTC
- Message-ID
- <alpine.DEB.1.00.0905241937350.26154@pacific.mpi-cbg.de>
- In-Reply-To
- <alpine.LFD.2.01.0905230859290.3555@localhost.localdomain>
Hi,
On Sat, 23 May 2009, Linus Torvalds wrote:
Show 26 quoted lines
> On Sat, 23 May 2009, Johannes Schindelin wrote:
> > On Fri, 15 May 2009, Linus Torvalds wrote:
> >
> > > On Fri, 15 May 2009, Johannes Schindelin wrote:
> > > >
> > > > fd = mkstemp(template);
> > > > + if (fd < 0) {
> > > > + release_pack_memory((size_t)-1ll, -1);
> > > > + fd = mkstemp(template);
> > >
> > > This is wrong. You can't use "template" twice. You need to re-initialize
> > > it. The first one will blow away the XXXX pattern.
> >
> > Turns out that would be awkward, as the xmkstemp() function would have to
> > copy the template just in case mkstemp() fails due to too many open files,
> > and of course it would need to release the copy afterwards.
> >
> > OTOH we cannot just use the initialized filename, because there
> > might be a race condition with another process, right?
>
> Correct. You basically need to have the caller re-create the template. We
> already do that in some other cases: see odb_mkstemp(), or
> create_tempfile(). Both of them do that template re-creation on failure,
> and try again.
>
> You could save off the template into a local temporary array, of course.I'll let it slip, due to time constraints.
Thanks, Dscho