Subject: Re: sendfile()
To: None <netbsd-users@netbsd.org>
From: Thor Lancelot Simon <tls@rek.tjls.com>
List: netbsd-users
Date: 07/08/2003 04:36:39
On Tue, Jul 08, 2003 at 12:08:25AM +0200, Christian Biere wrote:
> Manuel Bouyer <bouyer@antioche.eu.org> wrote:
> 
> > On Mon, Jul 07, 2003 at 03:55:55PM -0500, Douglas G. Phillips wrote:
> > > Is there an equivalent to the linux sendfile() in NetBSD?
> > 
> > There isn't. However, -current has a zero-copy TCP path for write(),
> > so mmap()ing the file and write()ing it in large chunks would probably
> > to the same.
> 
> mmap() can cause SIGSEGV or SIGBUS for various reasons. IIRC, sendfile()
> won't cause a crash but return an error code instead. Recovering from
> a SIGSEGV/SIGBUS is somewhat ugly. I think you can prevent this by
> using mlock/munlock() but these need root privileges on some operating
> systems and I don't know what's their effect on performance.

Uh, no.  I have indeed used operating systems where your claim about
mmap() was true -- though only for *writes to the mapped region* -- but
even the OS vendors in question would admit that that was a significant
bug if pressed hard enough.

You will not get SIGSEGV or SIGBUS from a write() of pages from a valid
mmap() mapping under NetBSD.  (If you do, please file a PR immediately).

Thor