Async: Further callbacks will no longer be called after an EAGAIN.
For context, see discussion here https://gitter.im/nim-lang/Nim?at=583090a2df9f0f6e7f576e43 or here http://irclogs.nim-lang.org/19-11-2016.html#17:30:59.
This commit is contained in:
parent
9ca3ae14ab
commit
d847d35009
1 changed files with 14 additions and 4 deletions
|
|
@ -1062,6 +1062,11 @@ else:
|
||||||
let currentCBs = data.readCBs
|
let currentCBs = data.readCBs
|
||||||
data.readCBs = @[]
|
data.readCBs = @[]
|
||||||
for cb in currentCBs:
|
for cb in currentCBs:
|
||||||
|
if data.readCBs.len > 0:
|
||||||
|
# A callback has already returned with EAGAIN, don't call any
|
||||||
|
# others until next `poll`.
|
||||||
|
data.readCBs.add(cb)
|
||||||
|
else:
|
||||||
if not cb(data.fd):
|
if not cb(data.fd):
|
||||||
# Callback wants to be called again.
|
# Callback wants to be called again.
|
||||||
data.readCBs.add(cb)
|
data.readCBs.add(cb)
|
||||||
|
|
@ -1070,6 +1075,11 @@ else:
|
||||||
let currentCBs = data.writeCBs
|
let currentCBs = data.writeCBs
|
||||||
data.writeCBs = @[]
|
data.writeCBs = @[]
|
||||||
for cb in currentCBs:
|
for cb in currentCBs:
|
||||||
|
if data.writeCBs.len > 0:
|
||||||
|
# A callback has already returned with EAGAIN, don't call any
|
||||||
|
# others until next `poll`.
|
||||||
|
data.writeCBs.add(cb)
|
||||||
|
else:
|
||||||
if not cb(data.fd):
|
if not cb(data.fd):
|
||||||
# Callback wants to be called again.
|
# Callback wants to be called again.
|
||||||
data.writeCBs.add(cb)
|
data.writeCBs.add(cb)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue