Fix StackSender.Send to always honor the `W` and `R` modes, by:
1) returning a valid Sender and Receiver when the respective flags are set, and
2) returning a value which doesn't need to be Closed, when they are not.
This also moves `NopSender` and `NopReceiver` out of `utils`, to prevent
a circular dependency.
Signed-off-by: Solomon Hykes <solomon@docker.com>
StackSender.Send and Hub.Send now return a valid Sender and Receiver
when the corresponding flags are set in `mode`.
Signed-off-by: Solomon Hykes <solomon@docker.com>
Each transport is responsible for implementing file passing using the
best available method.
Current state of implementation:
* inmem: full
* unix: not yet implemented
* `utils.Buffer`: a Sender which stores messages in a slice
* `utils.Copy`: beam equivalent of `io.Copy`
* `utlis.NopSender`: a Sender which silently discards messages
* `utlis.NopReceiver`: a Receiver which always returns EOF
Copy can now handle arbitrary nesting of streams, without knowing the
underlying type of either the source or destination.
It does this by attempting `SendTo` and `ReceiveFrom`, then if that is
not supported, falling back to nested copies in separate goroutines.
Signed-off-by: Solomon Hykes <solomon@docker.com>
StackSender forwards beam messages to a dynamic list of backend receivers.
New backends are stacked on top. When a message is sent, each backend is
tried until one succeeds. Any failing backends encountered along the way
are removed from the queue.
Signed-off-by: Solomon Hykes <solomon@docker.com>
* Copy is the beam equivalent of `io.Copy`
* `ReceiveFrom` is the beam equivalent of `io.ReadFrom`
* `SendTo` is the beam equivalent of `io.WriteTo`
Signed-off-by: Solomon Hykes <solomon@docker.com>
This introduces a superficial change to the Beam API:
* `beam.SendPipe` is renamed to the more accurate `beam.SendRPipe`
* `beam.SendWPipe` is introduced as a mirror to `SendRPipe`
There is no other change in the beam API.
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This is needed for Send/Recieve to correctly handle borders between
the messages.
The framing uses a single 32bit uint32 length for each frame, of which
the high bit is used to indicate whether the message contains a file
descriptor or not. This is enough to separate out each message sent
and to decide to which message each file descriptors belongs, even
though multiple Sends may be coalesced into a single read, and/or one
Send can be split into multiple writes.
Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
These are failing, and indicate things that need to be fixed. The
primarily problem is the lack of framing between beam messages.
Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
[solomon@docker.com: rebased on master]
Signed-off-by: Solomon Hykes <solomon@docker.com>