parent
5efa089196
commit
224f92e172
|
@ -260,6 +260,7 @@ proc accept(s: Switch, transport: Transport) {.async.} = # noraises
|
||||||
# file-handle limit (or another non-fatal error),
|
# file-handle limit (or another non-fatal error),
|
||||||
# we can get one on the next try
|
# we can get one on the next try
|
||||||
debug "Unable to get a connection"
|
debug "Unable to get a connection"
|
||||||
|
upgrades.release()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# set the direction of this bottom level transport
|
# set the direction of this bottom level transport
|
||||||
|
|
|
@ -72,15 +72,6 @@ proc setupTcpTransportTracker(): TcpTransportTracker =
|
||||||
result.isLeaked = leakTransport
|
result.isLeaked = leakTransport
|
||||||
addTracker(TcpTransportTrackerName, result)
|
addTracker(TcpTransportTrackerName, result)
|
||||||
|
|
||||||
proc getObservedAddr(client: StreamTransport): Future[MultiAddress] {.async.} =
|
|
||||||
try:
|
|
||||||
return MultiAddress.init(client.remoteAddress).tryGet()
|
|
||||||
except CatchableError as exc:
|
|
||||||
trace "Failed to create observedAddr", exc = exc.msg
|
|
||||||
if not(isNil(client) and client.closed):
|
|
||||||
await client.closeWait()
|
|
||||||
raise exc
|
|
||||||
|
|
||||||
proc connHandler*(self: TcpTransport,
|
proc connHandler*(self: TcpTransport,
|
||||||
client: StreamTransport,
|
client: StreamTransport,
|
||||||
observedAddr: Opt[MultiAddress],
|
observedAddr: Opt[MultiAddress],
|
||||||
|
@ -241,7 +232,7 @@ method accept*(self: TcpTransport): Future[Connection] {.async, gcsafe.} =
|
||||||
|
|
||||||
let transp = await finished
|
let transp = await finished
|
||||||
try:
|
try:
|
||||||
let observedAddr = await getObservedAddr(transp)
|
let observedAddr = MultiAddress.init(transp.remoteAddress).tryGet()
|
||||||
return await self.connHandler(transp, Opt.some(observedAddr), Direction.In)
|
return await self.connHandler(transp, Opt.some(observedAddr), Direction.In)
|
||||||
except CancelledError as exc:
|
except CancelledError as exc:
|
||||||
transp.close()
|
transp.close()
|
||||||
|
@ -282,7 +273,7 @@ method dial*(
|
||||||
await connect(address, flags = self.clientFlags)
|
await connect(address, flags = self.clientFlags)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
let observedAddr = await getObservedAddr(transp)
|
let observedAddr = MultiAddress.init(transp.remoteAddress).tryGet()
|
||||||
return await self.connHandler(transp, Opt.some(observedAddr), Direction.Out)
|
return await self.connHandler(transp, Opt.some(observedAddr), Direction.Out)
|
||||||
except CatchableError as err:
|
except CatchableError as err:
|
||||||
await transp.closeWait()
|
await transp.closeWait()
|
||||||
|
|
Loading…
Reference in New Issue