Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Commit

Permalink
Merge pull request #167 from jonboulle/master
Browse files Browse the repository at this point in the history
lib/repository2: fix parallel pull synchronisation
  • Loading branch information
alban committed May 30, 2016
2 parents ba503aa + 08bd690 commit a2baa79
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/internal/backend/repository/repository2.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"regexp"
"strconv"
"strings"
"sync"
"time"

"github.com/appc/docker2aci/lib/common"
Expand Down Expand Up @@ -80,13 +81,17 @@ func (rb *RepositoryBackend) buildACIV2(layerIDs []string, dockerURL *types.Pars

var errChannels []chan error
closers := make([]io.ReadCloser, len(layerIDs))
var wg sync.WaitGroup
for i, layerID := range layerIDs {
errChan := make(chan error)
wg.Add(1)
errChan := make(chan error, 1)
errChannels = append(errChannels, errChan)
// https://github.com/golang/go/wiki/CommonMistakes
i := i // golang--
layerID := layerID
go func() {
defer wg.Done()

manifest := rb.imageManifests[*dockerURL]

layerIndex, err := getLayerIndex(layerID, manifest)
Expand Down Expand Up @@ -120,6 +125,8 @@ func (rb *RepositoryBackend) buildACIV2(layerIDs []string, dockerURL *types.Pars
errChan <- nil
}()
}
// Need to wait for all of the readers to be added to the copier (which happens during rb.getLayerV2)
wg.Wait()
err = copier.PrintAndWait(os.Stderr, 500*time.Millisecond, nil)
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit a2baa79

Please sign in to comment.