Skip to content

Commit

Permalink
Handle Windows ERROR_NETNAME_DELETED in accept()
Browse files Browse the repository at this point in the history
This error code indicates that server socket is already
closed, so we raise a TransportClosedError.

Fixes CI failure in Windows.
  • Loading branch information
markspanbroek committed Jun 15, 2021
1 parent 6b89f09 commit 50d3b27
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libp2p/transports/tcptransport.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{.push raises: [Defect].}

import std/[oids, sequtils]
import std/[oids, sequtils, os]
import chronos, chronicles
import transport,
../errors,
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 50d3b27

Please sign in to comment.