diff options
author | bptato <nincsnevem662@gmail.com> | 2023-06-07 13:15:17 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-06-07 13:19:02 +0200 |
commit | d78298ae3369374bf7bf31592513d112c75a9601 (patch) | |
tree | e8daf184adb0b09d48d53bf123f23a5d2a7b8d86 /src/buffer | |
parent | c15d04041b1b8660000a1517b9d4bfc06f2cb490 (diff) | |
download | chawan-d78298ae3369374bf7bf31592513d112c75a9601.tar.gz |
Clean up stream error handling
* sread now raises EOFError if readData returns too few bytes * buffer handleError ignores unregistered fds like client * client handleError ignores unregistered fds like buffer
Diffstat (limited to 'src/buffer')
-rw-r--r-- | src/buffer/buffer.nim | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/buffer/buffer.nim b/src/buffer/buffer.nim index dc41ba6c..77772532 100644 --- a/src/buffer/buffer.nim +++ b/src/buffer/buffer.nim @@ -75,7 +75,6 @@ type Buffer* = ref object rfd: int # file descriptor of command pipe fd: int # file descriptor of buffer source - oldfd: int # fd after being unregistered alive: bool readbufsize: int contenttype: string @@ -663,7 +662,7 @@ proc finishLoad(buffer: Buffer): EmptyPromise = p = EmptyPromise() p.resolve() buffer.selector.unregister(buffer.fd) - buffer.oldfd = buffer.fd + buffer.loader.unregistered.add(buffer.fd) buffer.fd = -1 buffer.istream.close() return p @@ -1133,8 +1132,8 @@ proc handleRead(buffer: Buffer, fd: int) = elif fd in buffer.loader.ongoing: #TODO something with readablestream? discard - elif buffer.fd == -1 and buffer.oldfd == fd: - discard #TODO hack + elif fd in buffer.loader.unregistered: + discard # ignore else: assert false proc handleError(buffer: Buffer, fd: int, err: OSErrorCode) = @@ -1149,8 +1148,8 @@ proc handleError(buffer: Buffer, fd: int, err: OSErrorCode) = elif fd in buffer.loader.ongoing: #TODO something with readablestream? discard - elif buffer.fd == -1 and fd == buffer.oldfd: - discard #TODO hack + elif fd in buffer.loader.unregistered: + discard # ignore else: assert false, $fd & ": " & $err @@ -1169,6 +1168,7 @@ proc runBuffer(buffer: Buffer, rfd: int) = assert buffer.window != nil assert buffer.window.timeouts.runTimeoutFd(event.fd) buffer.window.runJSJobs() + buffer.loader.unregistered.setLen(0) buffer.pstream.close() buffer.loader.quit() quit(0) |