From 195e1f19b06095f39a4fb0da46dfab2ec5b10e9a Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 13 Jan 2011 12:36:14 +0100 Subject: 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." --- erts/emulator/drivers/win32/win_efile.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'erts/emulator/drivers/win32') 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); +} -- cgit v1.2.3