Fix hidden exceptions in transports.
This commit is contained in:
parent
d949710d8d
commit
7e8ecb1dd0
|
@ -3,7 +3,7 @@ version = "2.0.1"
|
||||||
author = "Status Research & Development GmbH"
|
author = "Status Research & Development GmbH"
|
||||||
description = "Asyncdispatch2"
|
description = "Asyncdispatch2"
|
||||||
license = "Apache License 2.0 or MIT"
|
license = "Apache License 2.0 or MIT"
|
||||||
skipDirs = @["tests", "Nim", "nim"]
|
skipDirs = @["tests", "Nim", "nim", "benchmarks"]
|
||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ when defined(windows):
|
||||||
transp.state.incl({ReadEof, ReadPaused})
|
transp.state.incl({ReadEof, ReadPaused})
|
||||||
fromSockAddr(transp.raddr, transp.ralen, raddr.address, raddr.port)
|
fromSockAddr(transp.raddr, transp.ralen, raddr.address, raddr.port)
|
||||||
transp.buflen = bytesCount
|
transp.buflen = bytesCount
|
||||||
discard transp.function(transp, raddr)
|
asyncCheck transp.function(transp, raddr)
|
||||||
elif int(err) == ERROR_OPERATION_ABORTED:
|
elif int(err) == ERROR_OPERATION_ABORTED:
|
||||||
# CancelIO() interrupt
|
# CancelIO() interrupt
|
||||||
transp.state.incl(ReadPaused)
|
transp.state.incl(ReadPaused)
|
||||||
|
@ -150,7 +150,7 @@ when defined(windows):
|
||||||
transp.setReadError(err)
|
transp.setReadError(err)
|
||||||
transp.state.incl(ReadPaused)
|
transp.state.incl(ReadPaused)
|
||||||
transp.buflen = 0
|
transp.buflen = 0
|
||||||
discard transp.function(transp, raddr)
|
asyncCheck transp.function(transp, raddr)
|
||||||
else:
|
else:
|
||||||
## Initiation
|
## Initiation
|
||||||
if transp.state * {ReadEof, ReadClosed, ReadError} == {}:
|
if transp.state * {ReadEof, ReadClosed, ReadError} == {}:
|
||||||
|
@ -180,7 +180,7 @@ when defined(windows):
|
||||||
transp.state.incl(ReadPaused)
|
transp.state.incl(ReadPaused)
|
||||||
transp.setReadError(err)
|
transp.setReadError(err)
|
||||||
transp.buflen = 0
|
transp.buflen = 0
|
||||||
discard transp.function(transp, raddr)
|
asyncCheck transp.function(transp, raddr)
|
||||||
break
|
break
|
||||||
|
|
||||||
proc resumeRead(transp: DatagramTransport) {.inline.} =
|
proc resumeRead(transp: DatagramTransport) {.inline.} =
|
||||||
|
@ -330,7 +330,7 @@ else:
|
||||||
if res >= 0:
|
if res >= 0:
|
||||||
fromSockAddr(transp.raddr, transp.ralen, raddr.address, raddr.port)
|
fromSockAddr(transp.raddr, transp.ralen, raddr.address, raddr.port)
|
||||||
transp.buflen = res
|
transp.buflen = res
|
||||||
discard transp.function(transp, raddr)
|
asyncCheck transp.function(transp, raddr)
|
||||||
else:
|
else:
|
||||||
let err = osLastError()
|
let err = osLastError()
|
||||||
if int(err) == EINTR:
|
if int(err) == EINTR:
|
||||||
|
@ -338,7 +338,7 @@ else:
|
||||||
else:
|
else:
|
||||||
transp.buflen = 0
|
transp.buflen = 0
|
||||||
transp.setReadError(err)
|
transp.setReadError(err)
|
||||||
discard transp.function(transp, raddr)
|
asyncCheck transp.function(transp, raddr)
|
||||||
break
|
break
|
||||||
|
|
||||||
proc writeDatagramLoop(udata: pointer) =
|
proc writeDatagramLoop(udata: pointer) =
|
||||||
|
|
|
@ -469,16 +469,14 @@ when defined(windows):
|
||||||
else:
|
else:
|
||||||
if not isNil(server.init):
|
if not isNil(server.init):
|
||||||
var transp = server.init(server, server.asock)
|
var transp = server.init(server, server.asock)
|
||||||
discard server.function(
|
let ntransp = newStreamSocketTransport(server.asock,
|
||||||
server,
|
server.bufferSize,
|
||||||
newStreamSocketTransport(server.asock, server.bufferSize,
|
transp)
|
||||||
transp)
|
asyncCheck server.function(server, ntransp)
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
discard server.function(
|
let ntransp = newStreamSocketTransport(server.asock,
|
||||||
server,
|
server.bufferSize, nil)
|
||||||
newStreamSocketTransport(server.asock, server.bufferSize, nil)
|
asyncCheck server.function(server, ntransp)
|
||||||
)
|
|
||||||
elif int32(ovl.data.errCode) == ERROR_OPERATION_ABORTED:
|
elif int32(ovl.data.errCode) == ERROR_OPERATION_ABORTED:
|
||||||
# CancelIO() interrupt
|
# CancelIO() interrupt
|
||||||
server.asock.closeAsyncSocket()
|
server.asock.closeAsyncSocket()
|
||||||
|
@ -713,10 +711,10 @@ else:
|
||||||
if sock != asyncInvalidSocket:
|
if sock != asyncInvalidSocket:
|
||||||
if not isNil(server.init):
|
if not isNil(server.init):
|
||||||
var transp = server.init(server, sock)
|
var transp = server.init(server, sock)
|
||||||
discard server.function(server,
|
asyncCheck server.function(server,
|
||||||
newStreamSocketTransport(sock, server.bufferSize, transp))
|
newStreamSocketTransport(sock, server.bufferSize, transp))
|
||||||
else:
|
else:
|
||||||
discard server.function(server,
|
asyncCheck server.function(server,
|
||||||
newStreamSocketTransport(sock, server.bufferSize, nil))
|
newStreamSocketTransport(sock, server.bufferSize, nil))
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue