From 96fd5ca88d9ca38824ccc0aebe4943fc37e1cfca Mon Sep 17 00:00:00 2001 From: bptato Date: Thu, 15 Feb 2024 23:44:55 +0100 Subject: so close! but I forgot to ensure the output stream gets closed. :( --- src/loader/loader.nim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/loader') 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 -- cgit 1.4.1-2-gfad0