diff options
author | bptato <nincsnevem662@gmail.com> | 2023-05-09 12:34:58 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-05-09 12:34:58 +0200 |
commit | 87f9bd656b2a8a8d4ebd029ba6a78f1dc93558eb (patch) | |
tree | c3b7e4f3500512baef2064986cfdf5701c988e29 /src/display/client.nim | |
parent | e0a8b27068ac8fc61a243bae685c23a14976f619 (diff) | |
download | chawan-87f9bd656b2a8a8d4ebd029ba6a78f1dc93558eb.tar.gz |
Improve debugging, reduce crashes
Loader no longer dies when not everything is read from the stream.
Diffstat (limited to 'src/display/client.nim')
-rw-r--r-- | src/display/client.nim | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/display/client.nim b/src/display/client.nim index 59557f36..cd2c9f5d 100644 --- a/src/display/client.nim +++ b/src/display/client.nim @@ -330,10 +330,19 @@ proc handleRead(client: Client, fd: int) = if s.len > prefix.len: client.console.err.write(s) client.console.err.flush() + elif fd in client.loader.connecting: + client.loader.onConnected(fd) + client.runJSJobs() + elif fd in client.loader.ongoing: + #TODO something with readablestream? + discard else: let container = client.fdmap[fd] client.pager.handleEvent(container) +proc flushConsole*(client: Client) {.jsfunc.} = + client.handleRead(client.dispatcher.forkserver.estream.fd) + proc handleError(client: Client, fd: int) = if client.console.tty != nil and fd == client.console.tty.getFileHandle(): #TODO do something here... @@ -343,6 +352,12 @@ proc handleError(client: Client, fd: int) = #TODO do something here... stderr.write("Fork server crashed :(\n") quit(1) + elif fd in client.loader.connecting: + #TODO handle error? + discard + elif fd in client.loader.ongoing: + #TODO something with readablestream? + discard else: if fd in client.fdmap: let container = client.fdmap[fd] @@ -392,8 +407,15 @@ proc inputLoop(client: Client) = client.pager.showAlerts() client.pager.draw() +func hasSelectFds(client: Client): bool = + return client.timeouts.len > 0 or + client.intervals.len > 0 or + client.pager.numload > 0 or + client.loader.connecting.len > 0 or + client.loader.ongoing.len > 0 + proc headlessLoop(client: Client) = - while client.timeouts.len + client.intervals.len != 0 or client.pager.numload > 0: + while client.hasSelectFds(): let events = client.selector.select(-1) for event in events: if Read in event.events: |