Merge pull request #4900 from cheatfate/asyncerronly
asyncdispatch: Fix handle of error only events.
This commit is contained in:
commit
bf92efc570
2 changed files with 14 additions and 14 deletions
|
|
@ -1055,7 +1055,7 @@ else:
|
||||||
# so that exceptions can be raised from `send(...)` and
|
# so that exceptions can be raised from `send(...)` and
|
||||||
# `recv(...)` routines.
|
# `recv(...)` routines.
|
||||||
|
|
||||||
if EvRead in info.events:
|
if EvRead in info.events or info.events == {EvError}:
|
||||||
# Callback may add items to ``data.readCBs`` which causes issues if
|
# Callback may add items to ``data.readCBs`` which causes issues if
|
||||||
# we are iterating over ``data.readCBs`` at the same time. We therefore
|
# we are iterating over ``data.readCBs`` at the same time. We therefore
|
||||||
# make a copy to iterate over.
|
# make a copy to iterate over.
|
||||||
|
|
@ -1066,7 +1066,7 @@ else:
|
||||||
# Callback wants to be called again.
|
# Callback wants to be called again.
|
||||||
data.readCBs.add(cb)
|
data.readCBs.add(cb)
|
||||||
|
|
||||||
if EvWrite in info.events:
|
if EvWrite in info.events or info.events == {EvError}:
|
||||||
let currentCBs = data.writeCBs
|
let currentCBs = data.writeCBs
|
||||||
data.writeCBs = @[]
|
data.writeCBs = @[]
|
||||||
for cb in currentCBs:
|
for cb in currentCBs:
|
||||||
|
|
|
||||||
|
|
@ -1194,21 +1194,21 @@ else:
|
||||||
var fd = keys[i].fd.SocketHandle
|
var fd = keys[i].fd.SocketHandle
|
||||||
let events = keys[i].events
|
let events = keys[i].events
|
||||||
|
|
||||||
if Event.Read in events:
|
if Event.Read in events or events == {Event.Error}:
|
||||||
let cb = keys[i].data.readCB
|
let cb = keys[i].data.readCB
|
||||||
doAssert(cb != nil)
|
if cb != nil:
|
||||||
if cb(fd.AsyncFD):
|
if cb(fd.AsyncFD):
|
||||||
p.selector.withData(fd, adata) do:
|
p.selector.withData(fd, adata) do:
|
||||||
if adata.readCB == cb:
|
if adata.readCB == cb:
|
||||||
adata.readCB = nil
|
adata.readCB = nil
|
||||||
|
|
||||||
if Event.Write in events:
|
if Event.Write in events or events == {Event.Error}:
|
||||||
let cb = keys[i].data.writeCB
|
let cb = keys[i].data.writeCB
|
||||||
doAssert(cb != nil)
|
if cb != nil:
|
||||||
if cb(fd.AsyncFD):
|
if cb(fd.AsyncFD):
|
||||||
p.selector.withData(fd, adata) do:
|
p.selector.withData(fd, adata) do:
|
||||||
if adata.writeCB == cb:
|
if adata.writeCB == cb:
|
||||||
adata.writeCB = nil
|
adata.writeCB = nil
|
||||||
|
|
||||||
when supportedPlatform:
|
when supportedPlatform:
|
||||||
if (customSet * events) != {}:
|
if (customSet * events) != {}:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue