Skip to content

Commit

Permalink
platform/packet/console: keep a track of the console status
Browse files Browse the repository at this point in the history
it might prevent to close twice the channel

Signed-off-by: Mathieu Tortuyaux <[email protected]>
  • Loading branch information
tormath1 committed Dec 15, 2021
1 parent 99f59e6 commit 2315216
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions platform/machine/packet/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
)

type console struct {
pc *cluster
f *os.File
buf bytes.Buffer
done chan interface{}
pc *cluster
f *os.File
buf bytes.Buffer
closed bool
done chan interface{}
}

func (c *console) SSHClient(ip, user string) (*ssh.Client, error) {
Expand All @@ -38,7 +39,10 @@ func (c *console) Write(p []byte) (int, error) {
}

func (c *console) Close() error {
close(c.done)
if !c.closed {
close(c.done)
c.closed = !c.closed
}
return c.f.Close()
}

Expand Down

0 comments on commit 2315216

Please sign in to comment.