aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/unix/unix_efile.c
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/drivers/unix/unix_efile.c')
-rw-r--r--erts/emulator/drivers/unix/unix_efile.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/erts/emulator/drivers/unix/unix_efile.c b/erts/emulator/drivers/unix/unix_efile.c
index 5b001b3819..8b612164da 100644
--- a/erts/emulator/drivers/unix/unix_efile.c
+++ b/erts/emulator/drivers/unix/unix_efile.c
@@ -1471,31 +1471,24 @@ efile_fadvise(Efile_error* errInfo, int fd, Sint64 offset,
#ifdef HAVE_SENDFILE
int
efile_sendfile(Efile_error* errInfo, int in_fd, int out_fd,
- off_t *offset, size_t *count)
+ off_t offset, size_t *ret_nbytes)
{
#if defined(__linux__) || (defined(__sun) && defined(__SVR4))
- ssize_t retval = sendfile(out_fd, in_fd, offset, *count);
- if (retval >= 0) {
- if (retval != *count) {
- *count = retval;
- retval = -1;
- errno = EAGAIN;
- } else {
- *count = retval;
- }
- } else if (retval == -1 && (errno == EINTR || errno == EAGAIN)) {
- *count = 0;
- }
+ ssize_t retval;
+ do {
+ retval = sendfile(out_fd, in_fd, &offset, *ret_nbytes);
+ } while (retval == -1 && (errno == EINTR || errno == EAGAIN));
+ *ret_nbytes = retval;
return check_error(retval == -1 ? -1 : 0, errInfo);
#elif defined(DARWIN)
- off_t len = *count;
+ off_t len = *ret_nbytes;
int retval = sendfile(in_fd, out_fd, *offset, &len, NULL, 0);
- *count = len;
+ *ret_nbytes = len;
return check_error(retval, errInfo);
#elif defined(__FreeBSD__) || defined(__DragonFly__)
off_t len = 0;
- int retval = sendfile(in_fd, out_fd, *offset, *count, NULL, &len, 0);
- *count = len;
+ int retval = sendfile(in_fd, out_fd, *offset, *nbytes, NULL, &len, 0);
+ *nbytes = len;
return check_error(retval, errInfo);
#endif
}