Re: [PATCH] Fix handle leak in write_tree

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] Fix handle leak in write_tree

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:06

"Alex Riesen" [off-list ref] writes:
... Isn't such kind of resource control _generally_ nicer to implement
in the top levels of a program?
In theory perhaps, but my understanding of our use of atexit()
is to clean them up in situations beyond the control of the top
levels of a program, most notably upon exit on signal.

Re: [PATCH] Fix handle leak in write_tree

From: Alex Riesen <hidden>
Date: 2016-06-15 22:43:07

Junio C Hamano, Tue, Apr 24, 2007 11:33:48 +0200:
quoted
... Isn't such kind of resource control _generally_ nicer to implement
in the top levels of a program?
In theory perhaps, but my understanding of our use of atexit()
is to clean them up in situations beyond the control of the top
levels of a program, most notably upon exit on signal.
struct git_context;
/* or whatever is the latest name for the repo bookeeping is.
   It have to be passed to every git-related function anyway. */

struct lock_file *open_index_locked(struct git_context *, int die_on_error);
int commit_index_locked(struct git_context *, struct lock_file *);
... and so on.

Then let the top level call something like

    git_cleanup(struct git_context *);

in its _own_ signal or atexit handlers. If it didn't setup the
handlers, than perhaps it did want it so (leaving tempfiles behind is
sometimes done on purpose). Or it _is_ a bug, but then it is clear:
you have to cleanup, and you do git's part of cleanup with
git_cleanup.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help