about summary refs log tree commit diff stats
path: root/src/io
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-11-07 21:14:25 +0100
committerbptato <nincsnevem662@gmail.com>2024-11-07 21:15:21 +0100
commit2ee9bc323c14de75c147c1d2051bdbf0cd6e28cf (patch)
tree5c2333cb402811c0fa350fc91766ff47755a9e07 /src/io
parentcea3303b71f5fc4f9b0eefa7c557f0d5980bc526 (diff)
downloadchawan-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.nim6
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()