Skip to content

Commit

Permalink
Fix to use proper context
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshi Muraoka committed Jul 19, 2019
1 parent b0e4c76 commit 48324e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ func (c *Cluster) Start(ctx context.Context, r *Runtime) error {
for _, n := range c.Nodes {
n := n
if n.TPM {
env.Go(n.StartSWTPM)
env.Go(func(ctx2 context.Context) error {
// reference the original context because ctx2 will soon be cancelled.
return n.StartSWTPM(ctx)
})
for {
_, err := os.Stat(n.swtpmSocket)
if err == nil {
Expand Down
8 changes: 6 additions & 2 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,16 @@ func (n *Node) StartSWTPM(ctx context.Context) error {
return err
}

err = well.CommandContext(ctx, "swtpm", "socket",
c := well.CommandContext(ctx, "swtpm", "socket",
"--tpmstate", "dir="+dirName,
"--tpm2",
"--ctrl",
"type=unixio,path="+n.swtpmSocket,
).Start()
)
c.Stdout = os.Stdout
c.Stderr = os.Stderr

err = c.Start()
if err != nil {
return err
}
Expand Down

0 comments on commit 48324e6

Please sign in to comment.