diff options
| author | bptato <nincsnevem662@gmail.com> | 2025-02-11 16:17:09 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2025-02-26 19:58:08 +0100 |
| commit | 55ffd92756faa3b60e3472404025a18509e0fce2 (patch) | |
| tree | 5ce18a089ad3c657a3270000d01f64f7b5717b6a /src/server/buffer.nim | |
| parent | 7ba1c5de335468f77d891b31ab5d0536f1addd25 (diff) | |
| download | chawan-55ffd92756faa3b60e3472404025a18509e0fce2.tar.gz | |
dynstream: remove exceptions
Now we just pass down the value of n and check errno, plus
readDataLoop/writeDataLoop returns a bool indicating whether it failed.
For now this seems to work OK, but maybe I'll add a better abstraction
in the future.
EOFError is still used for handling failed packets; this is brittle,
and should be replaced once we have a proper buffering mechanism for
them. (That will also let us kill BufStream.)
Unrelated: this also fixes a bug in buffer with cacheId.
Diffstat (limited to 'src/server/buffer.nim')
| -rw-r--r-- | src/server/buffer.nim | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim index e7770f08..61642297 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -919,8 +919,8 @@ proc rewind(buffer: Buffer; data: InputData; offset: int; buffer.loader.unset(data) data.stream.sclose() buffer.loader.put(InputData(stream: response.body)) - data.stream.setBlocking(false) - buffer.pollData.register(data.stream.fd, POLLIN) + response.body.setBlocking(false) + buffer.pollData.register(response.body.fd, POLLIN) buffer.bytesRead = offset return true @@ -1100,9 +1100,8 @@ proc onload(buffer: Buffer; data: InputData) = var n = 0 while true: if not reprocess: - try: - n = data.stream.recvData(iq) - except ErrorAgain: + n = data.stream.readData(iq) + if n < 0: break buffer.bytesRead += n if n != 0: @@ -1864,7 +1863,7 @@ proc handleRead(buffer: Buffer; fd: int): bool = if fd == buffer.pstream.fd: try: buffer.readCommand() - except ErrorConnectionReset, EOFError: + except EOFError: #eprint "EOF error", $buffer.url & "\nMESSAGE:", # getCurrentExceptionMsg() & "\n", # getStackTrace(getCurrentException()) @@ -1954,7 +1953,7 @@ proc launchBuffer*(config: BufferConfig; url: URL; attrs: WindowAttributes; pstream: pstream, url: url, charsetStack: charsetStack, - cacheId: -1, + cacheId: cacheId, outputId: -1 ) buffer.window = newWindow( |