summaryrefslogtreecommitdiff
path: root/internal/clients/remote/connection.go
diff options
context:
space:
mode:
authorPaul Buetow <35781042+pbuetow@users.noreply.github.com>2020-09-19 19:52:11 +0100
committerGitHub <noreply@github.com>2020-09-19 19:52:11 +0100
commit3c889d2eed4e12af505ea84d46d8e52d21057a1f (patch)
tree8e6d9f697fe9a5c70f200d54745bb5daecac6bde /internal/clients/remote/connection.go
parentec67d9833095dfbe620dd3c99ea0caba391c4b87 (diff)
parentdf2ff83897cde61d04b12958c6f6d458c69502f4 (diff)
Merge pull request #14 from snonux/develop
Refactor context handling
Diffstat (limited to 'internal/clients/remote/connection.go')
-rw-r--r--internal/clients/remote/connection.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/internal/clients/remote/connection.go b/internal/clients/remote/connection.go
index 2d97d14..b29ffed 100644
--- a/internal/clients/remote/connection.go
+++ b/internal/clients/remote/connection.go
@@ -177,21 +177,21 @@ func (c *Connection) handle(ctx context.Context, cancel context.CancelFunc, sess
}
go func() {
- defer cancel()
io.Copy(stdinPipe, c.Handler)
+ cancel()
}()
go func() {
- defer cancel()
io.Copy(c.Handler, stdoutPipe)
+ cancel()
}()
go func() {
- defer cancel()
select {
case <-c.Handler.Done():
case <-ctx.Done():
}
+ cancel()
}()
// Send all commands to client.
@@ -207,5 +207,6 @@ func (c *Connection) handle(ctx context.Context, cancel context.CancelFunc, sess
}
<-ctx.Done()
+ c.Handler.Shutdown()
return nil
}