Skip to content

Commit eac743e

Browse files
committed
Fix ECANCELLED on Windows to be WSA_E_CANCELLED.
Windows' documentation says that `WSAECANCELLED` will be removed, so use `WSA_E_CANCELLED` instead.
1 parent c9bae12 commit eac743e

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/imp/libc/winsock_c.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,32 @@ pub(crate) const SHUT_RDWR: i32 = WinSock::SD_BOTH as _;
5151
pub(crate) const SHUT_RD: i32 = WinSock::SD_RECEIVE as _;
5252
pub(crate) const SHUT_WR: i32 = WinSock::SD_SEND as _;
5353

54+
// Include the contents of `WinSock`, renaming as needed to match POSIX.
55+
//
56+
// Use `WSA_E_CANCELLED` for `ECANCELED` instead of `WSAECANCELLED`, because
57+
// `WSAECANCELLED` will be removed in the future.
58+
// <https://docs.microsoft.com/en-us/windows/win32/api/ws2spi/nc-ws2spi-lpnsplookupserviceend#remarks>
5459
pub(crate) use WinSock::{
5560
closesocket as close, ioctlsocket as ioctl, WSAPoll as poll, ADDRESS_FAMILY as sa_family_t,
5661
ADDRINFOA as addrinfo, IN6_ADDR as in6_addr, IN_ADDR as in_addr, IPV6_MREQ as ipv6_mreq,
5762
IP_MREQ as ip_mreq, SOCKADDR as sockaddr, SOCKADDR_IN as sockaddr_in,
5863
SOCKADDR_IN6 as sockaddr_in6, SOCKADDR_STORAGE as sockaddr_storage, WSAEACCES as EACCES,
5964
WSAEADDRINUSE as EADDRINUSE, WSAEADDRNOTAVAIL as EADDRNOTAVAIL,
6065
WSAEAFNOSUPPORT as EAFNOSUPPORT, WSAEALREADY as EALREADY, WSAEBADF as EBADF,
61-
WSAECANCELLED as ECANCELED, WSAECONNABORTED as ECONNABORTED, WSAECONNREFUSED as ECONNREFUSED,
62-
WSAECONNRESET as ECONNRESET, WSAEDESTADDRREQ as EDESTADDRREQ, WSAEDISCON as EDISCON,
63-
WSAEDQUOT as EDQUOT, WSAEFAULT as EFAULT, WSAEHOSTDOWN as EHOSTDOWN,
64-
WSAEHOSTUNREACH as EHOSTUNREACH, WSAEINPROGRESS as EINPROGRESS, WSAEINTR as EINTR,
65-
WSAEINVAL as EINVAL, WSAEINVALIDPROCTABLE as EINVALIDPROCTABLE,
66-
WSAEINVALIDPROVIDER as EINVALIDPROVIDER, WSAEISCONN as EISCONN, WSAELOOP as ELOOP,
67-
WSAEMFILE as EMFILE, WSAEMSGSIZE as EMSGSIZE, WSAENAMETOOLONG as ENAMETOOLONG,
68-
WSAENETDOWN as ENETDOWN, WSAENETRESET as ENETRESET, WSAENETUNREACH as ENETUNREACH,
69-
WSAENOBUFS as ENOBUFS, WSAENOMORE as ENOMORE, WSAENOPROTOOPT as ENOPROTOOPT,
70-
WSAENOTCONN as ENOTCONN, WSAENOTEMPTY as ENOTEMPTY, WSAENOTSOCK as ENOTSOCK,
71-
WSAEOPNOTSUPP as EOPNOTSUPP, WSAEPFNOSUPPORT as EPFNOSUPPORT, WSAEPROCLIM as EPROCLIM,
72-
WSAEPROTONOSUPPORT as EPROTONOSUPPORT, WSAEPROTOTYPE as EPROTOTYPE,
66+
WSAECONNABORTED as ECONNABORTED, WSAECONNREFUSED as ECONNREFUSED, WSAECONNRESET as ECONNRESET,
67+
WSAEDESTADDRREQ as EDESTADDRREQ, WSAEDISCON as EDISCON, WSAEDQUOT as EDQUOT,
68+
WSAEFAULT as EFAULT, WSAEHOSTDOWN as EHOSTDOWN, WSAEHOSTUNREACH as EHOSTUNREACH,
69+
WSAEINPROGRESS as EINPROGRESS, WSAEINTR as EINTR, WSAEINVAL as EINVAL,
70+
WSAEINVALIDPROCTABLE as EINVALIDPROCTABLE, WSAEINVALIDPROVIDER as EINVALIDPROVIDER,
71+
WSAEISCONN as EISCONN, WSAELOOP as ELOOP, WSAEMFILE as EMFILE, WSAEMSGSIZE as EMSGSIZE,
72+
WSAENAMETOOLONG as ENAMETOOLONG, WSAENETDOWN as ENETDOWN, WSAENETRESET as ENETRESET,
73+
WSAENETUNREACH as ENETUNREACH, WSAENOBUFS as ENOBUFS, WSAENOMORE as ENOMORE,
74+
WSAENOPROTOOPT as ENOPROTOOPT, WSAENOTCONN as ENOTCONN, WSAENOTEMPTY as ENOTEMPTY,
75+
WSAENOTSOCK as ENOTSOCK, WSAEOPNOTSUPP as EOPNOTSUPP, WSAEPFNOSUPPORT as EPFNOSUPPORT,
76+
WSAEPROCLIM as EPROCLIM, WSAEPROTONOSUPPORT as EPROTONOSUPPORT, WSAEPROTOTYPE as EPROTOTYPE,
7377
WSAEPROVIDERFAILEDINIT as EPROVIDERFAILEDINIT, WSAEREFUSED as EREFUSED, WSAEREMOTE as EREMOTE,
7478
WSAESHUTDOWN as ESHUTDOWN, WSAESOCKTNOSUPPORT as ESOCKTNOSUPPORT, WSAESTALE as ESTALE,
7579
WSAETIMEDOUT as ETIMEDOUT, WSAETOOMANYREFS as ETOOMANYREFS, WSAEUSERS as EUSERS,
76-
WSAEWOULDBLOCK as EWOULDBLOCK, WSAEWOULDBLOCK as EAGAIN, WSAPOLLFD as pollfd, *,
80+
WSAEWOULDBLOCK as EWOULDBLOCK, WSAEWOULDBLOCK as EAGAIN, WSAPOLLFD as pollfd,
81+
WSA_E_CANCELLED as ECANCELED, *,
7782
};

0 commit comments

Comments
 (0)