diff options
author | bptato <nincsnevem662@gmail.com> | 2024-09-22 12:30:11 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-09-22 12:30:27 +0200 |
commit | 9386feca5e39b89676dd410f6331553c37434239 (patch) | |
tree | 281f2333f7977cd6ffb58ac2346ecfe8b8f37665 /src/local/client.nim | |
parent | 9c544ac50b271eef7533663082beb69ff65f6bea (diff) | |
download | chawan-9386feca5e39b89676dd410f6331553c37434239.tar.gz |
client: seqify fdmap
Diffstat (limited to 'src/local/client.nim')
-rw-r--r-- | src/local/client.nim | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/local/client.nim b/src/local/client.nim index bf276aa3..c8bf9b24 100644 --- a/src/local/client.nim +++ b/src/local/client.nim @@ -57,7 +57,7 @@ type alive: bool config {.jsget.}: Config consoleWrapper: ConsoleWrapper - fdmap: Table[int, Container] + fdmap: seq[Container] feednext: bool pager {.jsget.}: Pager pressed: tuple[col: int; row: int] @@ -380,7 +380,7 @@ proc acceptBuffers(client: Client) = let stream = container.iface.stream let fd = int(stream.source.fd) client.selector.unregister(fd) - client.fdmap.del(fd) + client.fdmap[fd] = nil stream.sclose() elif container.process != -1: # connecting to buffer process let i = pager.findProcMapItem(container.process) @@ -441,6 +441,8 @@ proc acceptBuffers(client: Client) = loader.shareCachedItem(container.cacheId, loader.clientPid) container.setCloneStream(stream, registerFun) let fd = int(stream.fd) + if client.fdmap.len <= fd: + client.fdmap.setLen(fd + 1) client.fdmap[fd] = container client.selector.registerHandle(fd, {Read}, 0) pager.handleEvents(container) @@ -524,14 +526,14 @@ proc handleError(client: Client; fd: int) = elif (let i = client.pager.findConnectingContainer(fd); i != -1): client.pager.handleConnectingContainerError(i) else: - if fd in client.fdmap: + if fd < client.fdmap.len and client.fdmap[fd] != nil: let container = client.fdmap[fd] if container != client.consoleWrapper.container: client.console.error("Error in buffer", $container.url) else: client.consoleWrapper.container = nil client.selector.unregister(fd) - client.fdmap.del(fd) + client.fdmap[fd] = nil if client.consoleWrapper.container != nil: client.showConsole() else: |