[darcs-users] System.IO.Posix.MMap.mmapFile: unable to mmap file
Judah Jacobson
judah.jacobson at gmail.com
Wed Feb 4 22:41:52 UTC 2009
On Wed, Feb 4, 2009 at 9:59 AM, Eric Kow <kowey at darcs.net> wrote:
> On Wed, Feb 04, 2009 at 09:41:40 -0800, Judah Jacobson wrote:
>> I ran into this yesterday, and tracked it down to a bug when mmaping
>> empty files. I discussed this with Don Stewart over email and sent
>> him a fix (attached) against
>> http://code.haskell.org/~dons/code/bytestring-mmap/
>
> Interesting: I suppose this is what our internal version caught (by
> coindicence) with the l < mmap_limit test below?
>
>
> mmap :: FilePath -> IO (ForeignPtr Word8, Int)
> mmap f = do
> h <- openBinaryFile f ReadMode
> l <- fromIntegral `fmap` hFileSize h
> -- Don't bother mmaping small files because each mmapped file takes up
> -- at least one full VM block.
> if l < mmap_limit
> then do thefp <- BI.mallocByteString l
> debugForeignPtr thefp $ "mmap short file "++f
> withForeignPtr thefp $ \p-> hGetBuf h p l
> hClose h
> return (thefp, l)
Yeah, looks that way.
-Judah
More information about the darcs-users
mailing list