diff options
-rw-r--r-- | src/local/container.nim | 2 | ||||
-rw-r--r-- | src/server/buffer.nim | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/local/container.nim b/src/local/container.nim index 465d7b87..fb48e89e 100644 --- a/src/local/container.nim +++ b/src/local/container.nim @@ -1001,7 +1001,7 @@ proc setStream*(container: Container, stream: Stream) = stream.flush() container.load() else: - container.iface = container.iface.clone(stream) + container.iface = cloneInterface(stream) # Maybe we have to resume loading. Let's try. discard container.iface.load().then(proc(res: LoadResult) = container.onload(res)) diff --git a/src/server/buffer.nim b/src/server/buffer.nim index d6c00ef9..3be0fdcf 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -141,14 +141,19 @@ proc newBufferInterface*(stream: Stream): BufferInterface = stream: stream ) -proc clone*(iface: BufferInterface, stream: Stream): BufferInterface = - let iface2 = newBufferInterface(stream) +# After cloning a buffer, we need a new interface to the new buffer process. +# Here we create a new interface for that clone. +proc cloneInterface*(stream: Stream): BufferInterface = + let iface = newBufferInterface(stream) + # We have just fork'ed the buffer process inside an interface function, + # from which the new buffer is going to return as well. So we must also + # consume the return value of the clone function, which is the pid 0. var len: int var pid: Pid stream.sread(len) - stream.sread(iface2.packetid) + stream.sread(iface.packetid) stream.sread(pid) - return iface2 + return iface proc resolve*(iface: BufferInterface, packetid, len: int) = iface.opaque.len = len |