Menu

#7 Use mmap to send (and receive) files

open
nobody
5
2013-01-28
2012-03-13
Mikhail T.
No

Instead of a typical read-write loop, it may be beneficial in certain circumstances and on certain OSes to use mmap() to map the entire file into memory once. This can either just always be attempted, failing over to read-write, or triggered by an option given to sendfile().

Or, perhaps, the decision can be made in addBufferFromFile()...

If the filesize is known by recvfile, then it can also mmap the entire target (padded to match pagesize) and just keep writing to it (would need to truncate to the actual size before closing).

Discussion


Log in to post a comment.