PR #3431 caused connections closed on the remote side of a sshforward
session to not always result in the local side reading an EOF from the
connection. This change restores that behavior by closing the write side
of the forwarded connection after reading an EOF from the stream. Since
only the write side is being closed, it doesn't prevent the remote side
from continuing to read from the connection.
Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
The GRPC docs on RecvMsg say:
> RecvMsg blocks until it receives a message into m or the stream is
> done. It returns io.EOF when the client has performed a CloseSend.
> On any non-EOF error, the stream is aborted and the error contains
> the RPC status.
So if EOF is received that just means the client won't be sending
anymore data. But it may still be expecting to read data, so we
shouldn't close the conn yet.
This was encountered in real life when forwarding a docker socket to a
container, where it appears that the docker CLI closes its write side of
the connection when requesting the stdout/stderr but then expects to
read data after that.
Signed-off-by: Erik Sipsma <erik@sipsma.dev>
This package is an alias for "context", which has been part of
stdlib since go1.7, so should no longer be needed.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>