ws2_32: Make closesocket() more robust.
This commit is contained in:
parent
81598be9cf
commit
bf36fb0216
|
@ -2780,9 +2780,23 @@ int WINAPI WS_bind(SOCKET s, const struct WS_sockaddr* name, int namelen)
|
||||||
*/
|
*/
|
||||||
int WINAPI WS_closesocket(SOCKET s)
|
int WINAPI WS_closesocket(SOCKET s)
|
||||||
{
|
{
|
||||||
TRACE("socket %04lx\n", s);
|
int res = SOCKET_ERROR, fd;
|
||||||
if (CloseHandle(SOCKET2HANDLE(s))) return 0;
|
if (num_startup)
|
||||||
return SOCKET_ERROR;
|
{
|
||||||
|
fd = get_sock_fd(s, FILE_READ_DATA, NULL);
|
||||||
|
if (fd >= 0)
|
||||||
|
{
|
||||||
|
release_sock_fd(s, fd);
|
||||||
|
if (CloseHandle(SOCKET2HANDLE(s)))
|
||||||
|
res = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SetLastError(WSAENOTSOCK);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SetLastError(WSANOTINITIALISED);
|
||||||
|
TRACE("(socket %04lx) -> %d\n", s, res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_connect(int fd, const struct WS_sockaddr* name, int namelen)
|
static int do_connect(int fd, const struct WS_sockaddr* name, int namelen)
|
||||||
|
|
Loading…
Reference in New Issue