diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-10 22:52:13 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-10 22:54:31 +0100 |
commit | c4f0423e1a786fef840fd2f8c5c6bba550b353ab (patch) | |
tree | 9eb8007ca3af03f466dd3eedbb1e8b7e29e8ff94 /src/server | |
parent | d8c4b0979c6d1ff9f6edea650e3aeb1ca1e4a104 (diff) | |
download | chawan-c4f0423e1a786fef840fd2f8c5c6bba550b353ab.tar.gz |
loader: fix tee
My eyes are bleeding, but at least there is a chance that this does what I wanted. The previous tee implementation mixed buffer and loader fds, so it was fundamentally broken. Also, it used MultiStream which makes asynchronous streaming impossible. This time we use a flat array of output handles and link to them any buffers not written to the target yet.
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/buffer.nim | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/server/buffer.nim b/src/server/buffer.nim index e5cdf50d..851f04f1 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -919,7 +919,8 @@ proc clone*(buffer: Buffer, newurl: URL): Pid {.proxy.} = fds.add(fd) #TODO maybe we still have some data in sockets... we should probably split # this up to be executed after the main loop is finished... - buffer.loader.suspend(fds) + let parentPid = getpid() + buffer.loader.suspend(parentPid, fds) buffer.loader.addref() let pid = fork() if pid == -1: @@ -939,7 +940,7 @@ proc clone*(buffer: Buffer, newurl: URL): Pid {.proxy.} = for fd in buffer.loader.connecting.keys: cfds.add(fd) for fd in cfds: - let stream = SocketStream(buffer.loader.tee(fd)) + let stream = SocketStream(buffer.loader.tee(parentPid, fd)) var success: bool stream.sread(success) let sfd = int(stream.source.getFd()) @@ -957,7 +958,7 @@ proc clone*(buffer: Buffer, newurl: URL): Pid {.proxy.} = for fd in buffer.loader.ongoing.keys: ofds.add(fd) for fd in ofds: - let stream = SocketStream(buffer.loader.tee(fd)) + let stream = SocketStream(buffer.loader.tee(parentPid, fd)) var success: bool stream.sread(success) let sfd = int(stream.source.getFd()) @@ -997,7 +998,7 @@ proc clone*(buffer: Buffer, newurl: URL): Pid {.proxy.} = if needsPipe: let istrmp = newPosixStream(pipefd_write[1]) buffer.istream = newTeeStream(buffer.istream, istrmp) - buffer.loader.resume(fds) + buffer.loader.resume(parentPid, fds) return pid proc dispatchDOMContentLoadedEvent(buffer: Buffer) = |