mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 03:02:31 +00:00
Merge pull request #4900 from cheatfate/asyncerronly
asyncdispatch: Fix handle of error only events.
This commit is contained in:
@@ -1055,7 +1055,7 @@ else:
|
||||
# so that exceptions can be raised from `send(...)` and
|
||||
# `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
|
||||
# we are iterating over ``data.readCBs`` at the same time. We therefore
|
||||
# make a copy to iterate over.
|
||||
@@ -1066,7 +1066,7 @@ else:
|
||||
# Callback wants to be called again.
|
||||
data.readCBs.add(cb)
|
||||
|
||||
if EvWrite in info.events:
|
||||
if EvWrite in info.events or info.events == {EvError}:
|
||||
let currentCBs = data.writeCBs
|
||||
data.writeCBs = @[]
|
||||
for cb in currentCBs:
|
||||
|
||||
@@ -1194,21 +1194,21 @@ else:
|
||||
var fd = keys[i].fd.SocketHandle
|
||||
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
|
||||
doAssert(cb != nil)
|
||||
if cb(fd.AsyncFD):
|
||||
p.selector.withData(fd, adata) do:
|
||||
if adata.readCB == cb:
|
||||
adata.readCB = nil
|
||||
if cb != nil:
|
||||
if cb(fd.AsyncFD):
|
||||
p.selector.withData(fd, adata) do:
|
||||
if adata.readCB == cb:
|
||||
adata.readCB = nil
|
||||
|
||||
if Event.Write in events:
|
||||
if Event.Write in events or events == {Event.Error}:
|
||||
let cb = keys[i].data.writeCB
|
||||
doAssert(cb != nil)
|
||||
if cb(fd.AsyncFD):
|
||||
p.selector.withData(fd, adata) do:
|
||||
if adata.writeCB == cb:
|
||||
adata.writeCB = nil
|
||||
if cb != nil:
|
||||
if cb(fd.AsyncFD):
|
||||
p.selector.withData(fd, adata) do:
|
||||
if adata.writeCB == cb:
|
||||
adata.writeCB = nil
|
||||
|
||||
when supportedPlatform:
|
||||
if (customSet * events) != {}:
|
||||
|
||||
Reference in New Issue
Block a user