diff options
author | bptato <nincsnevem662@gmail.com> | 2024-11-07 21:14:25 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-11-07 21:15:21 +0100 |
commit | 2ee9bc323c14de75c147c1d2051bdbf0cd6e28cf (patch) | |
tree | 5c2333cb402811c0fa350fc91766ff47755a9e07 /src/io | |
parent | cea3303b71f5fc4f9b0eefa7c557f0d5980bc526 (diff) | |
download | chawan-2ee9bc323c14de75c147c1d2051bdbf0cd6e28cf.tar.gz |
poll: fix clear()
setLen(0) inside the events iterator was wrong; it should have just set all items to -1.
Diffstat (limited to 'src/io')
-rw-r--r-- | src/io/poll.nim | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/io/poll.nim b/src/io/poll.nim index 209218cd..62a34d91 100644 --- a/src/io/poll.nim +++ b/src/io/poll.nim @@ -54,7 +54,11 @@ proc trim(ctx: var PollData) = ctx.fds.setLen(i + 1) proc clear*(ctx: var PollData) = - ctx.fds.setLen(0) + # Do *not* set fds' len to 0, because this is called from inside the + # `events' iterator. + for it in ctx.fds.mitems: + it.fd = -1 + it.revents = 0 proc poll*(ctx: var PollData; timeout: cint) = ctx.trim() |