ws2_32-TransmitFile: Use correct type for return value of WS2_send, fix check in follow-up patch.

This commit is contained in:
Sebastian Lackner 2015-03-06 21:04:56 +01:00
parent 05cb27bb21
commit 9e39b598ad
3 changed files with 37 additions and 31 deletions

View File

@ -1,4 +1,4 @@
From 3174cffa6b4d0e934004db80506a153422c5af94 Mon Sep 17 00:00:00 2001
From fdb144e28efeb027f51fa7719ad5e95c757aea46 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 18:24:27 -0700
Subject: ws2_32: Implement a basic synchronous TransmitFile. (rev 2)
@ -9,7 +9,7 @@ Subject: ws2_32: Implement a basic synchronous TransmitFile. (rev 2)
2 files changed, 173 insertions(+), 7 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 96335cd..36ce0dd 100644
index 96335cd..779f618 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -378,6 +378,18 @@ struct ws2_accept_async
@ -94,7 +94,7 @@ index 96335cd..36ce0dd 100644
+ status = WS2_transmitfile_getbuffer( fd, wsa );
+ if (status == STATUS_PENDING)
+ {
+ DWORD n;
+ int n;
+
+ n = WS2_send( fd, &wsa->write );
+ if (n == -1 && errno != EAGAIN)

View File

@ -1,35 +1,38 @@
From 3ff267363ed9aa032ec26f14cd9f05b6c6af2113 Mon Sep 17 00:00:00 2001
From 8d15a4846ee5d8cfc5632e350e12caa73a79515a Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
Date: Tue, 3 Mar 2015 23:19:40 -0700
Subject: ws2_32: Add asynchronous support for TransmitFile. (rev 2)
---
dlls/ws2_32/socket.c | 72 +++++++++++++++++++++++++++++++++-----
dlls/ws2_32/socket.c | 76 ++++++++++++++++++++++++++++++++++------
dlls/ws2_32/tests/sock.c | 91 ++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 148 insertions(+), 15 deletions(-)
2 files changed, 151 insertions(+), 16 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index e45c838..f9cac67 100644
index 896397c..244f723 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -2632,13 +2632,45 @@ static NTSTATUS WS2_transmitfile_base( int fd, struct ws2_transmitfile_async *ws
@@ -2632,10 +2632,15 @@ static NTSTATUS WS2_transmitfile_base( int fd, struct ws2_transmitfile_async *ws
status = WS2_transmitfile_getbuffer( fd, wsa );
if (status == STATUS_PENDING)
{
+ IO_STATUS_BLOCK *iosb = (IO_STATUS_BLOCK *)wsa->write.user_overlapped;
DWORD n;
int n;
n = WS2_send( fd, &wsa->write );
if (n == -1 && errno != EAGAIN)
- if (n == -1 && errno != EAGAIN)
+ if (n >= 0)
+ {
+ if (iosb) iosb->Information += n;
+ }
+ else if (errno != EAGAIN)
return wsaErrStatus();
+
+ if (iosb) iosb->Information += n;
+ }
+
+ return status;
+}
+
+/***********************************************************************
}
@@ -2643,26 +2648,48 @@ static NTSTATUS WS2_transmitfile_base( int fd, struct ws2_transmitfile_async *ws
}
/***********************************************************************
+ * WS2_async_transmitfile (INTERNAL)
+ *
+ * Asynchronous callback for overlapped TransmitFile operations.
@ -49,16 +52,19 @@ index e45c838..f9cac67 100644
+ }
+ if (status == STATUS_PENDING)
+ return status;
}
+ }
+
+ iosb->u.Status = status;
+ if (wsa->write.user_overlapped->hEvent)
+ NtSetEvent(wsa->write.user_overlapped->hEvent, NULL);
+ release_async_io( &wsa->io );
return status;
}
@@ -2649,20 +2681,13 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
+ return status;
+}
+
+/***********************************************************************
* TransmitFile
*/
static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD bytes_per_send,
LPOVERLAPPED overlapped, LPTRANSMIT_FILE_BUFFERS buffers,
DWORD flags )
{
@ -80,7 +86,7 @@ index e45c838..f9cac67 100644
TRACE("(%lx, %p, %d, %d, %p, %p, %d)\n", s, h, file_bytes, bytes_per_send, overlapped,
buffers, flags );
@@ -2709,7 +2734,36 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
@@ -2709,7 +2736,36 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
wsa->write.control = NULL;
wsa->write.n_iovecs = 0;
wsa->write.first_iovec = 0;

View File

@ -1,4 +1,4 @@
From 08bff2c19fbe3ac44b8c1323d50c0aabc8bb0ddc Mon Sep 17 00:00:00 2001
From fc0e93449a708ce3f89ae87f107f07fbed452936 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
Date: Wed, 4 Mar 2015 13:16:20 -0700
Subject: ws2_32: Add support for TF_DISCONNECT to TransmitFile.
@ -9,11 +9,11 @@ Subject: ws2_32: Add support for TF_DISCONNECT to TransmitFile.
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index f9cac67..6cc0a79 100644
index 244f723..10d30bd 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -2642,7 +2642,16 @@ static NTSTATUS WS2_transmitfile_base( int fd, struct ws2_transmitfile_async *ws
if (iosb) iosb->Information += n;
@@ -2644,7 +2644,16 @@ static NTSTATUS WS2_transmitfile_base( int fd, struct ws2_transmitfile_async *ws
return wsaErrStatus();
}
- return status;
@ -30,7 +30,7 @@ index f9cac67..6cc0a79 100644
}
/***********************************************************************
@@ -2681,6 +2690,7 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
@@ -2683,6 +2692,7 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
LPOVERLAPPED overlapped, LPTRANSMIT_FILE_BUFFERS buffers,
DWORD flags )
{
@ -38,7 +38,7 @@ index f9cac67..6cc0a79 100644
IO_STATUS_BLOCK *iosb = (IO_STATUS_BLOCK *)overlapped;
union generic_unix_sockaddr uaddr;
unsigned int uaddrlen = sizeof(uaddr);
@@ -2703,8 +2713,8 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
@@ -2705,8 +2715,8 @@ static BOOL WINAPI WS2_TransmitFile( SOCKET s, HANDLE h, DWORD file_bytes, DWORD
WSASetLastError( WSAENOTCONN );
return FALSE;
}