windows: Provide a close(2) that can close both file handles and sockets

This commit is contained in:
Martin Willi 2013-11-21 16:27:21 +01:00
parent 740404d481
commit efcf249aeb
2 changed files with 22 additions and 0 deletions

View File

@ -331,6 +331,22 @@ static bool check_dontwait(int *flags)
return FALSE;
}
/**
* See header
*/
#undef close
int windows_close(int fd)
{
int ret;
ret = close(fd);
if (ret == -1 && errno == EBADF)
{ /* Winsock socket? */
ret = wserr(closesocket(fd));
}
return ret;
}
/**
* See header
*/

View File

@ -264,6 +264,12 @@ int socketpair(int domain, int type, int protocol, int sv[2]);
*/
#define ECONNRESET ENXIO
/**
* close(2) working for file handles and Winsock sockets
*/
#define close windows_close
int windows_close(int fd);
/**
* recv(2) with support for MSG_DONTWAIT
*/