windows: Provide a close(2) that can close both file handles and sockets
This commit is contained in:
parent
740404d481
commit
efcf249aeb
|
@ -331,6 +331,22 @@ static bool check_dontwait(int *flags)
|
||||||
return FALSE;
|
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
|
* See header
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -264,6 +264,12 @@ int socketpair(int domain, int type, int protocol, int sv[2]);
|
||||||
*/
|
*/
|
||||||
#define ECONNRESET ENXIO
|
#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
|
* recv(2) with support for MSG_DONTWAIT
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue