summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-06-25 18:02:10 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-06-25 18:02:11 (GMT)
commitc5baf18a404a9713e1b75161855cacbfec32fcf2 (patch)
tree4e0abcbb51224f859308e28ffaa61652030c172a /sha1_file.c
parentc53312583b2d25b6ed5f0aa421993795743d1da6 (diff)
parent9ca0aaf6de357d46916d81ca40c47886092fe610 (diff)
downloadgit-c5baf18a404a9713e1b75161855cacbfec32fcf2.zip
git-c5baf18a404a9713e1b75161855cacbfec32fcf2.tar.gz
git-c5baf18a404a9713e1b75161855cacbfec32fcf2.tar.bz2
Merge branch 'jk/diagnose-config-mmap-failure' into maint
The configuration reader/writer uses mmap(2) interface to access the files; when we find a directory, it barfed with "Out of memory?". * jk/diagnose-config-mmap-failure: xmmap(): drop "Out of memory?" config.c: rewrite ENODEV into EISDIR when mmap fails config.c: avoid xmmap error messages config.c: fix mmap leak when writing config read-cache.c: drop PROT_WRITE from mmap of index
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sha1_file.c b/sha1_file.c
index ac0ca1a..56c69ce 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -707,8 +707,8 @@ static void mmap_limit_check(size_t length)
(uintmax_t)length, (uintmax_t)limit);
}
-void *xmmap(void *start, size_t length,
- int prot, int flags, int fd, off_t offset)
+void *xmmap_gently(void *start, size_t length,
+ int prot, int flags, int fd, off_t offset)
{
void *ret;
@@ -719,12 +719,19 @@ void *xmmap(void *start, size_t length,
return NULL;
release_pack_memory(length);
ret = mmap(start, length, prot, flags, fd, offset);
- if (ret == MAP_FAILED)
- die_errno("Out of memory? mmap failed");
}
return ret;
}
+void *xmmap(void *start, size_t length,
+ int prot, int flags, int fd, off_t offset)
+{
+ void *ret = xmmap_gently(start, length, prot, flags, fd, offset);
+ if (ret == MAP_FAILED)
+ die_errno("mmap failed");
+ return ret;
+}
+
void close_pack_windows(struct packed_git *p)
{
while (p->windows) {