about summary refs log tree commit diff stats
path: root/src/loader
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-02-15 23:44:55 +0100
committerbptato <nincsnevem662@gmail.com>2024-02-15 23:52:24 +0100
commit96fd5ca88d9ca38824ccc0aebe4943fc37e1cfca (patch)
tree377a2ea5940567a10a8c89bbdcdec60ee22472e3 /src/loader
parent245609d564855a0e4b43066ff863919a4d7a19ff (diff)
downloadchawan-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.nim12
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