net: remove more erroneous set constructions (#14252) [backport]

Refs #13764

(cherry picked from commit 1a1e9986a3)
This commit is contained in:
alaviss
2020-05-07 11:37:54 +00:00
committed by narimiran
parent 75abd4dc68
commit 8e5c389bef

View File

@@ -180,11 +180,16 @@ proc isDisconnectionError*(flags: set[SocketFlag],
## if flags contains ``SafeDisconn``.
when useWinVersion:
SocketFlag.SafeDisconn in flags and
lastError.int32 in {WSAECONNRESET, WSAECONNABORTED, WSAENETRESET,
WSAEDISCON, ERROR_NETNAME_DELETED}
(lastError.int32 == WSAECONNRESET or
lastError.int32 == WSAECONNABORTED or
lastError.int32 == WSAENETRESET or
lastError.int32 == WSAEDISCON or
lastError.int32 == ERROR_NETNAME_DELETED)
else:
SocketFlag.SafeDisconn in flags and
lastError.int32 in {ECONNRESET, EPIPE, ENETRESET}
(lastError.int32 == ECONNRESET or
lastError.int32 == EPIPE or
lastError.int32 == ENETRESET)
proc toOSFlags*(socketFlags: set[SocketFlag]): cint =
## Converts the flags into the underlying OS representation.