while I'm at it, kill this race condition in uploads, too

This commit is contained in:
Megan Marsh 2017-07-03 13:30:11 -07:00
parent d8637751a3
commit 9ee97aaa2a
1 changed files with 7 additions and 1 deletions

View File

@ -132,7 +132,12 @@ func (c *communicator) Start(cmd *packer.RemoteCmd) (err error) {
func (c *communicator) Upload(path string, r io.Reader, fi *os.FileInfo) (err error) {
// Pipe the reader through to the connection
streamId := c.mux.NextId()
go serveSingleCopy("uploadData", c.mux, streamId, nil, r)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
serveSingleCopy("uploadData", c.mux, streamId, nil, r)
}()
args := CommunicatorUploadArgs{
Path: path,
@ -144,6 +149,7 @@ func (c *communicator) Upload(path string, r io.Reader, fi *os.FileInfo) (err er
}
err = c.client.Call("Communicator.Upload", &args, new(interface{}))
wg.Wait()
return
}