[darcs-users] System.IO.Posix.MMap.mmapFile: unable to mmap file

Eric Kow kowey at darcs.net
Wed Feb 4 17:59:26 UTC 2009

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)

Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.osuosl.org/pipermail/darcs-users/attachments/20090204/0417f688/attachment.pgp 

More information about the darcs-users mailing list