diff options
author | bptato <nincsnevem662@gmail.com> | 2024-09-14 15:58:52 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-09-14 16:56:46 +0200 |
commit | 5b2a36579e53c69f154288a91ddc3e7c5375d7a6 (patch) | |
tree | 6b81b21aa15ef26031ce653ea972f75e00b1df0e /src/local/client.nim | |
parent | dfa1a4bc5ece3b8c333b9a47bab038ff6a162f5b (diff) | |
download | chawan-5b2a36579e53c69f154288a91ddc3e7c5375d7a6.tar.gz |
loader: refactor, misc optimizations & fixes
* factor out input/output handle tables; use a seq instead * add possibility to directly open cached items onto stdin (mainly an optimization for reading images, which are always cached) * close used handles on local CGI execution * make clone during load work again
Diffstat (limited to 'src/local/client.nim')
-rw-r--r-- | src/local/client.nim | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/local/client.nim b/src/local/client.nim index 02f497ff..e96b5163 100644 --- a/src/local/client.nim +++ b/src/local/client.nim @@ -483,11 +483,10 @@ proc handleRead(client: Client; fd: int) = if not hadlf: client.console.err.write('\n') client.console.err.sflush() - elif fd in client.loader.connecting: - client.loader.onConnected(fd) - client.runJSJobs() - elif fd in client.loader.ongoing: + elif (let data = client.loader.get(fd); data != nil): client.loader.onRead(fd) + if data of ConnectData: + client.runJSJobs() elif fd in client.loader.unregistered: discard # ignore else: @@ -517,11 +516,8 @@ proc handleError(client: Client; fd: int) = #TODO do something here... stderr.write("Fork server crashed :(\n") client.quit(1) - elif fd in client.loader.connecting: - #TODO handle error? - discard - elif fd in client.loader.ongoing: - client.loader.onError(fd) + elif client.loader.map[fd] != nil: + discard client.loader.onError(fd) #TODO handle connection error? elif fd in client.loader.unregistered: discard # already unregistered... elif (let i = client.pager.findConnectingContainer(fd); i != -1): @@ -594,8 +590,7 @@ proc inputLoop(client: Client) = func hasSelectFds(client: Client): bool = return not client.timeouts.empty or client.pager.numload > 0 or - client.loader.connecting.len > 0 or - client.loader.ongoing.len > 0 or + client.loader.mapFds > 0 or client.pager.procmap.len > 0 proc headlessLoop(client: Client) = |