about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-16 13:10:23 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-16 13:10:23 +0100
commitd3bfce47b16104ab3407b90c5f01f7ad160bb5c2 (patch)
tree9787165e644d790749abf57403660ea929ed793e /src
parent30d60d22d2f5f60a5e5020dcbd3cfdf1010ad4db (diff)
downloadchawan-d3bfce47b16104ab3407b90c5f01f7ad160bb5c2.tar.gz
loader: add missing flush() calls
Seems wise to flush before e.g. reading.

And unwise to enable buffering on tee() even though we disable it on
startRequest()
Diffstat (limited to 'src')
-rw-r--r--src/loader/loader.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim
index 595847a8..3040c579 100644
--- a/src/loader/loader.nim
+++ b/src/loader/loader.nim
@@ -861,7 +861,7 @@ proc resume*(loader: FileLoader; fds: seq[int]) =
   stream.close()
 
 proc tee*(loader: FileLoader; sourceId, targetPid: int): (SocketStream, int) =
-  let stream = loader.connect()
+  let stream = loader.connect(buffered = false)
   stream.swrite(lcTee)
   stream.swrite(sourceId)
   stream.swrite(targetPid)
@@ -877,6 +877,7 @@ proc addCacheFile*(loader: FileLoader; outputId, targetPid: int):
   stream.swrite(lcAddCacheFile)
   stream.swrite(outputId)
   stream.swrite(targetPid)
+  stream.flush()
   var outputId: int
   var cacheFile: string
   stream.sread(outputId)
@@ -983,6 +984,7 @@ proc shareCachedItem*(loader: FileLoader; id, targetPid: int) =
     stream.swrite(loader.clientPid)
     stream.swrite(targetPid)
     stream.swrite(id)
+    stream.close()
 
 proc passFd*(loader: FileLoader; id: string; fd: FileHandle) =
   let stream = loader.connect(buffered = false)
@@ -1006,6 +1008,7 @@ proc addClient*(loader: FileLoader; key: ClientKey; pid: int;
   stream.swrite(key)
   stream.swrite(pid)
   stream.swrite(config)
+  stream.flush()
   stream.sread(result)
   stream.close()