Skip to content

Commit

Permalink
Avoid parallel layer downloads in load command
Browse files Browse the repository at this point in the history
Signed-off-by: Doug MacEachern <[email protected]>
  • Loading branch information
dougm committed Feb 19, 2015
1 parent 934535d commit de35ef2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions graph/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ func (s *TagStore) recursiveLoad(eng *engine.Engine, address, tmpImageDir string
log.Debugf("Error validating ID: %s", err)
return err
}

// ensure no two downloads of the same layer happen at the same time
if c, err := s.poolAdd("pull", "layer:"+img.ID); err != nil {
if c != nil {
log.Debugf("Image (id: %s) load is already running, waiting: %v", img.ID, err)
<-c
return nil
}

return err
}

defer s.poolRemove("pull", "layer:"+img.ID)

if img.Parent != "" {
if !s.graph.Exists(img.Parent) {
if err := s.recursiveLoad(eng, img.Parent, tmpImageDir); err != nil {
Expand Down

0 comments on commit de35ef2

Please sign in to comment.