Commit 8034e91c authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer: Lock in RemoteCommand.ExitChan

parent 24237da3
...@@ -2,6 +2,7 @@ package packer ...@@ -2,6 +2,7 @@ package packer
import ( import (
"io" "io"
"sync"
"time" "time"
) )
...@@ -34,6 +35,8 @@ type RemoteCommand struct { ...@@ -34,6 +35,8 @@ type RemoteCommand struct {
Stderr io.Reader Stderr io.Reader
Exited bool Exited bool
ExitStatus int ExitStatus int
exitChanLock sync.Mutex
} }
// StdoutStream returns a channel that will be sent all the output // StdoutStream returns a channel that will be sent all the output
...@@ -47,9 +50,11 @@ func (r *RemoteCommand) StdoutChan() (<-chan string) { ...@@ -47,9 +50,11 @@ func (r *RemoteCommand) StdoutChan() (<-chan string) {
// the process exits. This can be used in cases such a select statement // the process exits. This can be used in cases such a select statement
// waiting on the process to end. // waiting on the process to end.
func (r *RemoteCommand) ExitChan() (<-chan int) { func (r *RemoteCommand) ExitChan() (<-chan int) {
// TODO(mitchellh): lock
// TODO(mitchellh): Something more efficient than multiple Wait() calls // TODO(mitchellh): Something more efficient than multiple Wait() calls
r.exitChanLock.Lock()
defer r.exitChanLock.Unlock()
// Make a single buffered channel so that the send doesn't block. // Make a single buffered channel so that the send doesn't block.
exitChan := make(chan int, 1) exitChan := make(chan int, 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment