about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-26 23:59:57 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-27 00:01:38 +0200
commit9b5e0ee59220e490d40aac6d53ad1ec5714a6ff1 (patch)
treea210f0c01feb2528996f7ee9fc51b0e516764c4e
parent7e42176f4f5e73ceaedadac0e326604d90ae443b (diff)
downloadchawan-9b5e0ee59220e490d40aac6d53ad1ec5714a6ff1.tar.gz
poll: unset unused fds in register
-rw-r--r--src/io/poll.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/io/poll.nim b/src/io/poll.nim
index f394233e..fe7aee56 100644
--- a/src/io/poll.nim
+++ b/src/io/poll.nim
@@ -14,7 +14,10 @@ iterator events*(ctx: PollData): TPollFd =
 
 proc register*(ctx: var PollData; fd: int; events: cshort) =
   if fd >= ctx.fds.len:
+    let olen = ctx.fds.len
     ctx.fds.setLen(fd + 1)
+    for i in olen ..< fd:
+      ctx.fds[i].fd = -1
   ctx.fds[fd].fd = cint(fd)
   ctx.fds[fd].events = events