[PATCH] Fix FreeBSD/Darwin and Linux sendfile

Jesse Miller jmiller at jmiller.com
Fri Mar 31 00:48:49 UTC 2017


https://github.com/samba-team/samba/pull/76

Use poll() to emulate a blocking sendfile().

This avoids spinning on EAGAIN/EWOULDBLOCK under Linux implementation,
which greatly reduces CPU usage.

(https://lists.samba.org/archive/samba/2013-September/175838.html)

This fixes FreeBSD/Darwin implementation, which under most cases did
not work, it would break early when nwritten == 0.  Which would happen
anytime it spun on EAGAIN writing 0 bytes.

(https://forums.freebsd.org/threads/55017/)


I believe other platforms sys_sendfile() code will also spin, but I don't have access to those platforms for testing, so they remain unchanged.

Jesse

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-source3__lib__sendfile.c.patch
Type: application/octet-stream
Size: 6345 bytes
Desc: patch-source3__lib__sendfile.c.patch
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170331/fe981fa2/patch-source3__lib__sendfile.c.obj>


More information about the samba-technical mailing list