diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-15 23:44:55 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-15 23:52:24 +0100 |
commit | 96fd5ca88d9ca38824ccc0aebe4943fc37e1cfca (patch) | |
tree | 377a2ea5940567a10a8c89bbdcdec60ee22472e3 /src/loader | |
parent | 245609d564855a0e4b43066ff863919a4d7a19ff (diff) | |
download | chawan-96fd5ca88d9ca38824ccc0aebe4943fc37e1cfca.tar.gz |
so close!
but I forgot to ensure the output stream gets closed. :(
Diffstat (limited to 'src/loader')
-rw-r--r-- | src/loader/loader.nim | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim index 712db932..d859ae34 100644 --- a/src/loader/loader.nim +++ b/src/loader/loader.nim @@ -210,14 +210,11 @@ proc loadStream(ctx: LoaderContext, handle: LoaderHandle, request: Request, if S_ISREG(stats.st_mode): # stdin is a regular file, so we can't select on it. let originalUrl = if handle.cached: originalUrl else: nil - let output = handle.output - output.ostream.setBlocking(false) + handle.output.ostream.setBlocking(false) ctx.addFd0(handle, originalUrl) - var nn = 0 while true: let buffer = newLoaderBuffer() let n = ps.recvData(buffer) - nn += n if n == 0: break var unregWrite: seq[OutputHandle] = @[] @@ -238,7 +235,12 @@ proc loadStream(ctx: LoaderContext, handle: LoaderHandle, request: Request, if n < buffer.cap: break for output in handle.outputs: - output.parent = nil + if output.registered: + output.parent = nil + output.istreamAtEnd = true + else: + output.ostream.close() + output.ostream = nil handle.outputs.setLen(0) handle.istream.close() handle.istream = nil |