sendfile() in samba?
tridge at samba.org
Fri May 25 02:28:23 GMT 2001
> > OOC, why are oplocks necessary for safely using sendfile()?
> 'Cos you don't want the filesize changing out from under
> you by another process..... that way lies sig11's :-).
it's not sig11's that are the problem (sendfile is not mmap). The
problem is error handling. If the sendfile returns short as the file
has been truncated by another process then we can't recover. The
header has already been sent saying that they are getting N bytes, and
we have to send N bytes. We could zero pad to N bytes, but that is
extremely dodgy - those zero bytes might mean something to the app at
the other end. We can't just drop the socket like you can do in http
as that will cause clients to get horrid error messages and
potentially data corruption.
If we have a kernel lease (oplock) before calling sendfile then we
know that nobody can change the file while we are sending, so its
More information about the samba-technical