diff options
author | Stefan Grundmann <[email protected]> | 2015-04-23 17:40:51 +0000 |
---|---|---|
committer | Stefan Grundmann <[email protected]> | 2015-04-23 18:32:40 +0000 |
commit | daaefc2fa63eb0c3fc8f6183ec1169733c2f2ea8 (patch) | |
tree | 2fb40823724e3ab5f0c8c111c05b2e00c7b63fd7 /erts/emulator/drivers/common | |
parent | 1756ef6ea4af36e061cdde92d1a87b3b225edea7 (diff) | |
download | otp-daaefc2fa63eb0c3fc8f6183ec1169733c2f2ea8.tar.gz otp-daaefc2fa63eb0c3fc8f6183ec1169733c2f2ea8.tar.bz2 otp-daaefc2fa63eb0c3fc8f6183ec1169733c2f2ea8.zip |
Fix FreeBSD sendfile
check (nbytes == 0 && d->c.sendfile.nbytes == 0) when efile_sendfile returns 0 and
has EAGAIN set.
FreeBSD sendfile(2) man page:
When using a socket marked for non-blocking I/O, sendfile() may send
fewer bytes than requested. In this case, the number of bytes
successfully written is returned in *sbytes (if specified), and the error
EAGAIN is returned.
The number of bytes successfully written can be 0. If this happens and
in a request handling either file:sendfile/2 or file:sendfile/5 with Bytes=0,
the sendfile loop will stop prematurely and file:sendfile will return
{ok, BytesSent} where BytesSent < DataAfterOffset, effectively breaking sendfile
support on FreeBSD.
Diffstat (limited to 'erts/emulator/drivers/common')
-rw-r--r-- | erts/emulator/drivers/common/efile_drv.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/erts/emulator/drivers/common/efile_drv.c b/erts/emulator/drivers/common/efile_drv.c index 518646649d..b2cfe70f94 100644 --- a/erts/emulator/drivers/common/efile_drv.c +++ b/erts/emulator/drivers/common/efile_drv.c @@ -1938,6 +1938,8 @@ static void invoke_sendfile(void *data) d->result_ok = 1; if (d->c.sendfile.nbytes != 0) d->c.sendfile.nbytes -= nbytes; + } else if (nbytes == 0 && d->c.sendfile.nbytes == 0) { + d->result_ok = 1; } else d->result_ok = 0; } else { |