diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-12 04:59:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-12 04:59:59 +0000 |
commit | 052282b2d174632c62327a1ccd2d839e8ab3ec9e (patch) | |
tree | 9604f20f0dc601f1b8f34d0adbd9fcdc57140b2d /network_io | |
parent | Releasing progress-linux version 1.7.2-3.2~progress7.99u1. (diff) | |
download | apr-052282b2d174632c62327a1ccd2d839e8ab3ec9e.tar.xz apr-052282b2d174632c62327a1ccd2d839e8ab3ec9e.zip |
Merging upstream version 1.7.5.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | network_io/win32/sendrecv.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/network_io/win32/sendrecv.c b/network_io/win32/sendrecv.c index 6620e13..4a01c09 100644 --- a/network_io/win32/sendrecv.c +++ b/network_io/win32/sendrecv.c @@ -255,11 +255,29 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, int disconnected = 0; int sendv_trailers = 0; char hdtrbuf[4096]; + LPFN_TRANSMITFILE pfn_transmit_file = NULL; + static GUID wsaid_transmitfile = WSAID_TRANSMITFILE; + DWORD dw; if (apr_os_level < APR_WIN_NT) { return APR_ENOTIMPL; } + /* According to documentation TransmitFile() should not be used directly. + * Pointer to function should retrieved using WSAIoctl: + * https://docs.microsoft.com/en-gb/windows/win32/api/mswsock/nf-mswsock-transmitfile#remarks + */ + if (WSAIoctl(sock->socketdes, SIO_GET_EXTENSION_FUNCTION_POINTER, + &wsaid_transmitfile, sizeof(wsaid_transmitfile), + &pfn_transmit_file, sizeof(pfn_transmit_file), + &dw, NULL, NULL) == SOCKET_ERROR) { + return apr_get_os_error(); + } + + if (dw != sizeof(pfn_transmit_file)) { + return APR_EINVAL; + } + /* Use len to keep track of number of total bytes sent (including headers) */ bytes_to_send = *len; *len = 0; @@ -351,13 +369,13 @@ APR_DECLARE(apr_status_t) apr_socket_sendfile(apr_socket_t *sock, sock->overlapped->OffsetHigh = (DWORD)(curoff >> 32); #endif /* XXX BoundsChecker claims dwFlags must not be zero. */ - rv = TransmitFile(sock->socketdes, /* socket */ - file->filehand, /* open file descriptor of the file to be sent */ - xmitbytes, /* number of bytes to send. 0=send all */ - 0, /* Number of bytes per send. 0=use default */ - sock->overlapped, /* OVERLAPPED structure */ - ptfb, /* header and trailer buffers */ - dwFlags); /* flags to control various aspects of TransmitFile */ + rv = pfn_transmit_file(sock->socketdes, /* socket */ + file->filehand, /* open file descriptor of the file to be sent */ + xmitbytes, /* number of bytes to send. 0=send all */ + 0, /* Number of bytes per send. 0=use default */ + sock->overlapped, /* OVERLAPPED structure */ + ptfb, /* header and trailer buffers */ + dwFlags); /* flags to control various aspects of TransmitFile */ if (!rv) { status = apr_get_netos_error(); if ((status == APR_FROM_OS_ERROR(ERROR_IO_PENDING)) || |