Commit b54b282a authored by Daniel Santos's avatar Daniel Santos Committed by Alexandre Julliard

ws2_32: WSASendTo() should clear last error on success.

parent cafec085
...@@ -2766,6 +2766,7 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, ...@@ -2766,6 +2766,7 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
} }
else NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)ws2_async_apc, else NtQueueApcThread( GetCurrentThread(), (PNTAPCFUNC)ws2_async_apc,
(ULONG_PTR)wsa, (ULONG_PTR)iosb, 0 ); (ULONG_PTR)wsa, (ULONG_PTR)iosb, 0 );
WSASetLastError(0);
return 0; return 0;
} }
...@@ -2830,6 +2831,7 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, ...@@ -2830,6 +2831,7 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
TRACE(" -> %i bytes\n", *lpNumberOfBytesSent); TRACE(" -> %i bytes\n", *lpNumberOfBytesSent);
release_sock_fd( s, fd ); release_sock_fd( s, fd );
WSASetLastError(0);
return 0; return 0;
error: error:
......
...@@ -2180,6 +2180,34 @@ end: ...@@ -2180,6 +2180,34 @@ end:
closesocket(v6); closesocket(v6);
} }
static void test_WSASendTo(void)
{
SOCKET s;
struct sockaddr_in addr;
char buf[12] = "hello world";
WSABUF data_buf;
DWORD bytesSent;
addr.sin_family = AF_INET;
addr.sin_port = htons(139);
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
data_buf.len = sizeof(buf);
data_buf.buf = buf;
if( (s = socket(AF_INET, SOCK_DGRAM, 0)) == INVALID_SOCKET) {
ok(0, "socket() failed error: %d\n", WSAGetLastError());
return;
}
WSASetLastError(12345);
if(WSASendTo(s, &data_buf, 1, &bytesSent, 0, (struct sockaddr*)&addr, sizeof(addr), NULL, NULL)) {
ok(0, "WSASendTo() failed error: %d\n", WSAGetLastError());
return;
}
ok(!WSAGetLastError(), "WSAGetLastError() should return zero after "
"a successful call to WSASendTo()\n");
}
/**************** Main program ***************/ /**************** Main program ***************/
START_TEST( sock ) START_TEST( sock )
...@@ -2219,6 +2247,8 @@ START_TEST( sock ) ...@@ -2219,6 +2247,8 @@ START_TEST( sock )
test_send(); test_send();
test_write_events(); test_write_events();
test_WSASendTo();
test_ipv6only(); test_ipv6only();
Exit(); Exit();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment