diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-06-25 11:49:48 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-25 11:49:48 -0700 |
commit | 1881d2b88c4b889dcb95782ad4bc5395808438e9 (patch) | |
tree | cab7b82ccfc98e89b355c3dc209b7ec6656e1b93 /compat | |
parent | 85785df6d6db50ff37d0ff1878c16ad69a063f6a (diff) | |
parent | 426ddeead6112955dfb50ccf9bb4af05d1ca9082 (diff) | |
download | git-1881d2b88c4b889dcb95782ad4bc5395808438e9.tar.gz |
Merge branch 'ym/fix-opportunistic-index-update-race' into maint
"git status", even though it is a read-only operation, tries to
update the index with refreshed lstat(2) info to optimize future
accesses to the working tree opportunistically, but this could
race with a "read-write" operation that modify the index while it
is running. Detect such a race and avoid overwriting the index.
* ym/fix-opportunistic-index-update-race:
read-cache.c: verify index file before we opportunistically update it
wrapper.c: add xpread() similar to xread()
Diffstat (limited to 'compat')
-rw-r--r-- | compat/mmap.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/compat/mmap.c b/compat/mmap.c index c9d46d1742..7f662fef7b 100644 --- a/compat/mmap.c +++ b/compat/mmap.c @@ -14,7 +14,7 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of } while (n < length) { - ssize_t count = pread(fd, (char *)start + n, length - n, offset + n); + ssize_t count = xpread(fd, (char *)start + n, length - n, offset + n); if (count == 0) { memset((char *)start+n, 0, length-n); @@ -22,8 +22,6 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of } if (count < 0) { - if (errno == EAGAIN || errno == EINTR) - continue; free(start); errno = EACCES; return MAP_FAILED; |