summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--network_io/win32/sendrecv.c32
2 files changed, 25 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e34afe03..c731fc816 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -160,7 +160,6 @@ SET(APR_INCLUDE_DIRECTORIES
SET(APR_SYSTEM_LIBS
ws2_32
- mswsock
rpcrt4
bcrypt
)
diff --git a/network_io/win32/sendrecv.c b/network_io/win32/sendrecv.c
index 0580e774f..21779082d 100644
--- a/network_io/win32/sendrecv.c
+++ b/network_io/win32/sendrecv.c
@@ -270,6 +270,24 @@ 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;
+
+ /* 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;
@@ -362,13 +380,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)) ||