From 50d3b2767f0b856b899b7a5f76a0edf3705d5288 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Wed, 19 May 2021 18:04:06 +0200 Subject: [PATCH] Handle Windows ERROR_NETNAME_DELETED in accept() This error code indicates that server socket is already closed, so we raise a TransportClosedError. Fixes CI failure in Windows. --- libp2p/transports/tcptransport.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libp2p/transports/tcptransport.nim b/libp2p/transports/tcptransport.nim index 3a12f7409b..9585133adf 100644 --- a/libp2p/transports/tcptransport.nim +++ b/libp2p/transports/tcptransport.nim @@ -9,7 +9,7 @@ {.push raises: [Defect].} -import std/[oids, sequtils] +import std/[oids, sequtils, os] import chronos, chronicles import transport, ../errors, @@ -203,8 +203,10 @@ method accept*(self: TcpTransport): Future[Session] {.async.} = except TransportOsError as exc: # TODO: it doesn't sound like all OS errors # can be ignored, we should re-raise those - # that can'self. + # that can't. debug "OS Error", exc = exc.msg + if defined(windows) and exc.code == OSErrorCode(64): # ERROR_NETNAME_DELETED + raise newTransportClosedError(exc) except TransportTooManyError as exc: debug "Too many files opened", exc = exc.msg except TransportUseClosedError as exc: