diff options
author | bptato <nincsnevem662@gmail.com> | 2024-09-03 01:17:53 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-09-03 01:22:00 +0200 |
commit | 298684d174be90be57967f15c2f1bf0d24ba2446 (patch) | |
tree | f4cbd02fecb39b39f931bceb1b79dbc439223d0f /src/loader/loader.nim | |
parent | 6d8c2fca2e39cc9f3cc9a99cac5584864eaa0ed4 (diff) | |
download | chawan-298684d174be90be57967f15c2f1bf0d24ba2446.tar.gz |
loader, client, buffer: use selectInto (not select)
select allocates. (makes sense, but I never realized...)
Diffstat (limited to 'src/loader/loader.nim')
-rw-r--r-- | src/loader/loader.nim | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim index b655b917..c882c227 100644 --- a/src/loader/loader.nim +++ b/src/loader/loader.nim @@ -216,7 +216,7 @@ proc unregister(ctx: LoaderContext; output: OutputHandle) = f.setLen(0) ctx.selector.count = oc - 1 else: - ctx.selector.unregister(int(output.ostream.fd)) + ctx.selector.unregister(fd) output.registered = false # Either write data to the target output, or append it to the list of buffers to @@ -953,11 +953,12 @@ proc finishCycle(ctx: LoaderContext; unregRead: var seq[LoaderHandle]; proc runFileLoader*(fd: cint; config: LoaderConfig) = var ctx = initLoaderContext(fd, config) let fd = int(ctx.ssock.sock.getFd()) + var keys: array[64, ReadyKey] while ctx.alive: - let events = ctx.selector.select(-1) + let count = ctx.selector.selectInto(-1, keys) var unregRead: seq[LoaderHandle] = @[] var unregWrite: seq[OutputHandle] = @[] - for event in events: + for event in keys.toOpenArray(0, count - 1): if Read in event.events: if event.fd == fd: # incoming connection ctx.acceptConnection() |