aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/win32
diff options
context:
space:
mode:
authorTuncer Ayaz <[email protected]>2011-01-13 12:36:14 +0100
committerLukas Larsson <[email protected]>2011-11-29 14:30:35 +0100
commit195e1f19b06095f39a4fb0da46dfab2ec5b10e9a (patch)
tree8f4a8c587b72c3a20d18b4cb6ccd7d1d52eb6286 /erts/emulator/drivers/win32
parent7292c3d9f5285592aa4de996f6f106cd365d7895 (diff)
downloadotp-195e1f19b06095f39a4fb0da46dfab2ec5b10e9a.tar.gz
otp-195e1f19b06095f39a4fb0da46dfab2ec5b10e9a.tar.bz2
otp-195e1f19b06095f39a4fb0da46dfab2ec5b10e9a.zip
Implement file:sendfile
Allow Erlang code to use sendfile() where available by wrapping it as file:sendfile/4 and file:sendfile/2. sendfile(2) - Linux man page: "sendfile() copies data between one file descriptor and another. Because this copying is done within the kernel, sendfile() is more efficient than the combination of read(2) and write(2), which would require transferring data to and from user space."
Diffstat (limited to 'erts/emulator/drivers/win32')
-rw-r--r--erts/emulator/drivers/win32/win_efile.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/erts/emulator/drivers/win32/win_efile.c b/erts/emulator/drivers/win32/win_efile.c
index 931bb196f1..0f41a09bf6 100644
--- a/erts/emulator/drivers/win32/win_efile.c
+++ b/erts/emulator/drivers/win32/win_efile.c
@@ -1581,3 +1581,27 @@ efile_fadvise(Efile_error* errInfo, int fd, Sint64 offset,
errno = ERROR_SUCCESS;
return check_error(0, errInfo);
}
+
+int
+efile_sendfile(Efile_error* errInfo, int in_fd, int out_fd,
+ off_t *offset, size_t *count)
+{
+ /* TODO: write proper Windows TransmitFile based implementation */
+ /* use overlapped I/O and driver_select on the structure? */
+ /* int res = efile_seek(errInfo, in_fd, *offset, EFILE_SEEK_SET, NULL); */
+ /* if (res) { */
+ /* /\* TODO: could in_fd be shared and require protecting/locking */
+ /* efile_seek/SetFilePointerEx? *\/ */
+ /* if (TransmitFile((SOCKET) out_fd, (HANDLE) in_fd, *count, */
+ /* 0, NULL, NULL, 0)) { */
+ /* return check_error(0, errInfo); */
+ /* } else { */
+ /* /\* TODO: correct error handling? *\/ */
+ /* return set_error(errInfo); */
+ /* } */
+ /* } else { */
+ /* return res; */
+ /* } */
+ errno = ENOTSUP;
+ return check_error(-1, errInfo);
+}