Re: [PATCH 1/2] commit-graph.c: remove temporary graph layers on exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 07, 2024 at 02:47:58PM -0700, Junio C Hamano wrote:

> Taylor Blau <me@xxxxxxxxxxxx> writes:
> 
> >> > -		result = rename(ctx->graph_name, final_graph_name);
> >> > +		result = rename_tempfile(&graph_layer, final_graph_name);
> >>
> >> Before this rename, after the close(fd) we saw in the previous hunk,
> >> there is one early error return when we fail to rename the base
> >> graph file.  Do we need to do anything there, or an unfinished
> >> tempfile getting removed at the process termination is sufficient
> >> for cleaning up the mess?
> >
> > We could explicitly clean it up, but we'll do so implicitly upon exit,
> > so I think it's fine to leave it as-is.
> 
> I am not worried about cleaning it up.  Upon exit, the underlying
> file descriptor will be closed, but this new code never does
> fclose() on the FILE* that has a buffer around the underlying file
> descriptor.  How are we guaranteeing that we are not losing anything
> buffered but not flushed yet?

I'm not sure I understand. There is no "FILE *" at all in this patch (we
use the descriptor directly via the hashfd interface). But even if there
were, if we leave without renaming the temp file into place, then that
tempfile will be deleted. So it wouldn't matter if we flushed to it or
not, because all of those byte are destined to be thrown away.

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux