diff options
-rw-r--r-- | src/display/client.nim | 2 | ||||
-rw-r--r-- | src/io/loader.nim | 7 | ||||
-rw-r--r-- | src/io/posixstream.nim | 5 | ||||
-rw-r--r-- | src/ips/socketstream.nim | 4 |
4 files changed, 11 insertions, 7 deletions
diff --git a/src/display/client.nim b/src/display/client.nim index 50d7383c..1902e122 100644 --- a/src/display/client.nim +++ b/src/display/client.nim @@ -84,7 +84,7 @@ proc `=destroy`(client: var ClientObj) = free(client.jsrt) proc doRequest(client: Client, req: Request): Response {.jsfunc.} = - client.loader.doRequest(req) + return client.loader.doRequest(req) proc interruptHandler(rt: JSRuntime, opaque: pointer): int {.cdecl.} = let client = cast[Client](opaque) diff --git a/src/io/loader.nim b/src/io/loader.nim index 4931d40b..d96d1a5a 100644 --- a/src/io/loader.nim +++ b/src/io/loader.nim @@ -106,10 +106,9 @@ proc runFileLoader*(fd: cint, config: LoaderConfig) = of QUIT: stream.close() break - except EOFError: - # End-of-file, quit. - break - stream.close() + except IOError: + # End-of-file, broken pipe, or something. + stream.close() curl_global_cleanup() ssock.close() quit(0) diff --git a/src/io/posixstream.nim b/src/io/posixstream.nim index fa0a35ca..10fd2237 100644 --- a/src/io/posixstream.nim +++ b/src/io/posixstream.nim @@ -33,6 +33,7 @@ proc raisePosixIOError*() = proc psReadData(s: Stream, buffer: pointer, len: int): int = assert len != 0 let s = cast[PosixStream](s) + let wasend = s.isend while result < len: let n = read(s.fd, cast[pointer](cast[int](buffer) + result), len) if n < 0: @@ -44,7 +45,9 @@ proc psReadData(s: Stream, buffer: pointer, len: int): int = break result += n if result == 0: - raise newException(EOFError, "eof") + if wasend: + raise newException(EOFError, "eof") + s.isend = true if result == -1: raisePosixIOError() diff --git a/src/ips/socketstream.nim b/src/ips/socketstream.nim index af173d1a..88023f07 100644 --- a/src/ips/socketstream.nim +++ b/src/ips/socketstream.nim @@ -17,6 +17,7 @@ type SocketStream* = ref object of Stream proc sockReadData(s: Stream, buffer: pointer, len: int): int = assert len != 0 let s = SocketStream(s) + let wasend = s.isend if s.blk: while result < len: let n = s.source.recv(cast[pointer](cast[int](buffer) + result), len - result) @@ -31,8 +32,9 @@ proc sockReadData(s: Stream, buffer: pointer, len: int): int = else: result = s.source.recv(buffer, len) if result == 0: + if wasend: + raise newException(EOFError, "eof") s.isend = true - raise newException(EOFError, "eof") if result < 0: raisePosixIOError() elif result == 0: |