mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-01-22 01:10:12 +00:00
Some fixes in state transition inside of datagram transport.
This commit is contained in:
parent
e5e710854f
commit
b3195b616d
@ -74,6 +74,8 @@ when defined(windows):
|
|||||||
while len(transp.queue) > 0:
|
while len(transp.queue) > 0:
|
||||||
if WritePending in transp.state:
|
if WritePending in transp.state:
|
||||||
## Continuation
|
## Continuation
|
||||||
|
if WriteClosed in transp.state:
|
||||||
|
break
|
||||||
transp.state.excl(WritePending)
|
transp.state.excl(WritePending)
|
||||||
let err = transp.wovl.data.errCode
|
let err = transp.wovl.data.errCode
|
||||||
let vector = transp.queue.popFirst()
|
let vector = transp.queue.popFirst()
|
||||||
@ -84,7 +86,7 @@ when defined(windows):
|
|||||||
transp.state.incl(WritePaused)
|
transp.state.incl(WritePaused)
|
||||||
vector.writer.complete()
|
vector.writer.complete()
|
||||||
else:
|
else:
|
||||||
transp.state = transp.state + {WritePaused, WriteError}
|
transp.state.incl({WritePaused, WriteError})
|
||||||
vector.writer.fail(getTransportOsError(err))
|
vector.writer.fail(getTransportOsError(err))
|
||||||
else:
|
else:
|
||||||
## Initiation
|
## Initiation
|
||||||
@ -106,13 +108,14 @@ when defined(windows):
|
|||||||
let err = osLastError()
|
let err = osLastError()
|
||||||
if int(err) == ERROR_OPERATION_ABORTED:
|
if int(err) == ERROR_OPERATION_ABORTED:
|
||||||
# CancelIO() interrupt
|
# CancelIO() interrupt
|
||||||
|
transp.state.excl(WritePending)
|
||||||
transp.state.incl(WritePaused)
|
transp.state.incl(WritePaused)
|
||||||
vector.writer.complete()
|
vector.writer.complete()
|
||||||
elif int(err) == ERROR_IO_PENDING:
|
elif int(err) == ERROR_IO_PENDING:
|
||||||
transp.queue.addFirst(vector)
|
transp.queue.addFirst(vector)
|
||||||
else:
|
else:
|
||||||
transp.state.excl(WritePending)
|
transp.state.excl(WritePending)
|
||||||
transp.state = transp.state + {WritePaused, WriteError}
|
transp.state.incl({WritePaused, WriteError})
|
||||||
vector.writer.fail(getTransportOsError(err))
|
vector.writer.fail(getTransportOsError(err))
|
||||||
else:
|
else:
|
||||||
transp.queue.addFirst(vector)
|
transp.queue.addFirst(vector)
|
||||||
@ -201,6 +204,7 @@ when defined(windows):
|
|||||||
var localSock: AsyncFD
|
var localSock: AsyncFD
|
||||||
assert(remote.family == local.family)
|
assert(remote.family == local.family)
|
||||||
assert(not isNil(cbproc))
|
assert(not isNil(cbproc))
|
||||||
|
assert(remote.family in {AddressFamily.IPv4, AddressFamily.IPv6})
|
||||||
|
|
||||||
if isNil(child):
|
if isNil(child):
|
||||||
result = DatagramTransport()
|
result = DatagramTransport()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user