Skip to content

Commit 7354ab6

Browse files
committed
Map ERROR_NETNAME_DELETED to canceled in make_err
IOCP delivers ERROR_NETNAME_DELETED (64) when closesocket() cancels pending overlapped I/O, despite MSDN documenting ERROR_OPERATION_ABORTED for that case. This became visible after SO_UPDATE_CONNECT_CONTEXT was added to ConnectEx sockets, which caused TLS shutdown tests to receive unmapped error 64.
1 parent b6bdaec commit 7354ab6

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

include/boost/corosio/detail/make_err.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@ make_err(int errn) noexcept
5252

5353
/** Convert a Windows error code to std::error_code.
5454
55-
Maps ERROR_OPERATION_ABORTED and ERROR_CANCELLED to capy::error::canceled.
55+
Maps ERROR_OPERATION_ABORTED, ERROR_CANCELLED, and
56+
ERROR_NETNAME_DELETED to capy::error::canceled.
5657
Maps ERROR_HANDLE_EOF to capy::error::eof.
5758
59+
ERROR_NETNAME_DELETED (64) is what IOCP actually delivers
60+
when closesocket() cancels pending overlapped I/O, despite
61+
MSDN documenting ERROR_OPERATION_ABORTED for that case.
62+
5863
@param dwError The Windows error code (DWORD).
5964
@return The corresponding std::error_code.
6065
*/
@@ -64,7 +69,8 @@ make_err(unsigned long dwError) noexcept
6469
if (dwError == 0)
6570
return {};
6671

67-
if (dwError == ERROR_OPERATION_ABORTED || dwError == ERROR_CANCELLED)
72+
if (dwError == ERROR_OPERATION_ABORTED || dwError == ERROR_CANCELLED ||
73+
dwError == ERROR_NETNAME_DELETED)
6874
return capy::error::canceled;
6975

7076
if (dwError == ERROR_HANDLE_EOF)

0 commit comments

Comments
 (0)