tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Equivalent of the system call sendfile

On Nov 25, 2008, at 5:39 PM, Thor Lancelot Simon wrote:

On Wed, Nov 26, 2008 at 12:02:18AM +0000, David Laight wrote:
On Tue, Nov 25, 2008 at 07:43:06PM +0000, Wouter Klouwen wrote:

So, you can use:
        void *addr = mmap(NULL, length, PROT_READ, MAP_FILE | MAP_SHARED,
                file descriptor, offset);
        send(socket, addr, length, 0);

Although you'd be better limiting the length of each mmap.
Otherwise you can run out of process VM for very large files.

Perhaps we should provide sendfile in libc, as an appropriate wrapper
around mmap() and write().

Of course, it would not be that hard to do it in the kernel and you'd have the bonus of not consuming a lot of userspace VM to do it.

On the other hand, perhaps encouraging use of this duplicative and,
honestly, pretty much dumb API is not something we should do.  If it
did anything meaningful with a non-blocking socket...

Thor Lancelot Simon
   "Even experienced UNIX users occasionally enter rm *.* at the UNIX
    prompt only to realize too late that they have removed the wrong
    segment of the directory structure." - Microsoft WSS whitepaper

-- thorpej

Home | Main Index | Thread Index | Old Index