ws2_32: Finish an overlapped send only if we sent everything.

This commit is contained in:
Mike Kaplinskiy 2011-01-24 00:19:25 -05:00 committed by Alexandre Julliard
parent a06144d9ca
commit 27b51ce6b0
2 changed files with 8 additions and 6 deletions

View File

@ -1806,7 +1806,11 @@ static NTSTATUS WS2_async_send(void* user, IO_STATUS_BLOCK* iosb, NTSTATUS statu
if (result >= 0) if (result >= 0)
{ {
status = STATUS_SUCCESS; if (wsa->first_iovec < wsa->n_iovecs)
status = STATUS_PENDING;
else
status = STATUS_SUCCESS;
iosb->Information += result; iosb->Information += result;
} }
else if (errno == EINTR || errno == EAGAIN) else if (errno == EINTR || errno == EAGAIN)
@ -3906,10 +3910,10 @@ static int WS2_sendto( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
wsa->completion_func = lpCompletionRoutine; wsa->completion_func = lpCompletionRoutine;
release_sock_fd( s, fd ); release_sock_fd( s, fd );
if (n == -1) if (n == -1 || n < totalLength)
{ {
iosb->u.Status = STATUS_PENDING; iosb->u.Status = STATUS_PENDING;
iosb->Information = 0; iosb->Information = n == -1 ? 0 : n;
SERVER_START_REQ( register_async ) SERVER_START_REQ( register_async )
{ {

View File

@ -2848,10 +2848,8 @@ static void test_send(void)
bytes_sent = 0; bytes_sent = 0;
ret = WSASend(dst, &buf, 1, &bytes_sent, 0, &ov, NULL); ret = WSASend(dst, &buf, 1, &bytes_sent, 0, &ov, NULL);
todo_wine ok((ret == SOCKET_ERROR && GetLastError() == ERROR_IO_PENDING) || broken(bytes_sent == buflen), ok((ret == SOCKET_ERROR && GetLastError() == ERROR_IO_PENDING) || broken(bytes_sent == buflen),
"Failed to start overlapped send %d - %d - %d/%d\n", ret, WSAGetLastError(), bytes_sent, buflen); "Failed to start overlapped send %d - %d - %d/%d\n", ret, WSAGetLastError(), bytes_sent, buflen);
if ( (ret != SOCKET_ERROR || GetLastError() != ERROR_IO_PENDING) && bytes_sent < buflen )
goto end;
/* don't check for completion yet, we may need to drain the buffer while still sending */ /* don't check for completion yet, we may need to drain the buffer while still sending */
set_blocking(src, FALSE); set_blocking(src, FALSE);