Commit 99f36f9b authored by Simon Persson's avatar Simon Persson

Make libgit2 close packfile file descriptors when done.

A problem is that bup archives can easily have over 1000 pack files, which is not normal for a git repo. libgit2 has not been designed for that, it keeps file descriptors open (presumably as an optimization).
This is a bit hackish fix since it's only done in one place. Seems to be enough for now.
parent fe4ee6ea
......@@ -370,11 +370,25 @@ static int pack_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p,
struct git_pack_entry e;
git_rawobj raw;
int error;
struct pack_backend *p_backend = (struct pack_backend *)backend;
size_t i;
if ((error = pack_entry_find(&e, (struct pack_backend *)backend, oid)) < 0 ||
if ((error = pack_entry_find(&e, p_backend, oid)) < 0 ||
(error = git_packfile_unpack(&raw, e.p, &e.offset)) < 0)
return error;
// Hackish workaround added by Simon Persson, to make it work with repos
// that have more than 1000 packfiles, usually runs into linux max open
// file descriptors (ulimit -n). Close all FDs when done with them.
for (i = 0; i < p_backend->packs.length; ++i) {
struct git_pack_file *p = git_vector_get(&p_backend->packs, i);
if (p->mwf.fd != -1) {
p->mwf.fd = -1;
*buffer_p =;
*len_p = raw.len;
*type_p = raw.type;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment