aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/unix
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-11-25 10:48:46 +0100
committerLukas Larsson <[email protected]>2011-12-01 14:10:02 +0100
commit0348a9c9c0114ddf83d776adc3d01ac60dfcccfc (patch)
tree109a4d4c9b55d5ef5a4a2cc2f49e9e64a1e748f5 /erts/emulator/drivers/unix
parent5ba916ef7ac71bd1e7e23b4c87ae6a472f14fd6c (diff)
downloadotp-0348a9c9c0114ddf83d776adc3d01ac60dfcccfc.tar.gz
otp-0348a9c9c0114ddf83d776adc3d01ac60dfcccfc.tar.bz2
otp-0348a9c9c0114ddf83d776adc3d01ac60dfcccfc.zip
Implement sendfile using blocking io in asynch threads
Move the command handling to outputv in preparation for header and trailer inclusion in the sendfile api. Use the standard efile communication functions for sendfile.
Diffstat (limited to 'erts/emulator/drivers/unix')
-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
}