Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/midx.c
diff options
context:
space:
mode:
authorDerrick Stolee <stolee@gmail.com>2020-04-24 16:17:16 +0300
committerJunio C Hamano <gitster@pobox.com>2020-04-24 23:09:49 +0300
commit6c7ff7cf7f431e4accf360c018149d1e263eaf06 (patch)
tree5c244a9b0d966aeeecdf6558afb5395e13a0c5ec /midx.c
parent6a22d521260f86dff8fe6f23ab329cebb62ba4f0 (diff)
multi-pack-index: close file descriptor after mmap
The multi-pack-index subsystem was not closing its file descriptor after memory-mapping the file contents. After this mmap() succeeds, there is no need to keep the file descriptor open. In fact, there is signficant reason to close it so we do not run out of descriptors. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'midx.c')
-rw-r--r--midx.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/midx.c b/midx.c
index f3e8dbc108..95d29ce462 100644
--- a/midx.c
+++ b/midx.c
@@ -68,9 +68,9 @@ struct multi_pack_index *load_multi_pack_index(const char *object_dir, int local
FREE_AND_NULL(midx_name);
midx_map = xmmap(NULL, midx_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ close(fd);
FLEX_ALLOC_MEM(m, object_dir, object_dir, strlen(object_dir));
- m->fd = fd;
m->data = midx_map;
m->data_len = midx_size;
m->local = local;
@@ -184,8 +184,6 @@ static void close_midx(struct multi_pack_index *m)
{
uint32_t i;
munmap((unsigned char *)m->data, m->data_len);
- close(m->fd);
- m->fd = -1;
for (i = 0; i < m->num_packs; i++) {
if (m->packs[i]) {