Re: [PATCH v3] packed_ref_cache: don't use mmap() for small files
- From
Jeff King <peff@peff.net>
- Date
- Jan 17, 2018, 22:09 UTC
- Message-ID
- <20180117220902.GA14952@sigill.intra.peff.net>
- In-Reply-To
- <20180116193815.4568-1-kgybels@infogroep.be>
On Tue, Jan 16, 2018 at 08:38:15PM +0100, Kim Gybels wrote:
Show 22 quoted lines
> Take a hint from commit ea68b0ce9f8 (hash-object: don't use mmap() for > small files, 2010-02-21) and use read() instead of mmap() for small > packed-refs files. > > This also fixes the problem[1] where xmmap() returns NULL for zero > length[2], for which munmap() later fails. > > Alternatively, we could simply check for NULL before munmap(), or > introduce xmunmap() that could be used together with xmmap(). However, > always setting snapshot->buf to a valid pointer, by relying on > xmalloc(0)'s fallback to 1-byte allocation, makes using snapshots > easier. > > [1] https://github.com/git-for-windows/git/issues/1410 > [2] Logic introduced in commit 9130ac1e196 (Better error messages for > corrupt databases, 2007-01-11) > > Signed-off-by: Kim Gybels <kgybels@infogroep.be> > --- > > Change since v2: removed separate case for zero length as suggested by Peff, > ensuring that snapshot->buf is always a valid pointer.
Thanks, this looks fine to me (I'd be curious to hear from Michael if this eliminates the need for the other patches).
-Peff