Skip to content

Commit

Permalink
Merge pull request #1133 from tonistiigi/concurrent-write
Browse files Browse the repository at this point in the history
remotecache: fix concurrent write
  • Loading branch information
tonistiigi authored Aug 15, 2019
2 parents 48f4a9b + 0d45d77 commit be0d75f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cache/remotecache/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"io"
"sync"
"time"

"github.com/containerd/containerd/content"
Expand Down Expand Up @@ -109,6 +110,7 @@ func (ci *contentCacheImporter) importInlineCache(ctx context.Context, dt []byte
return nil, err
}

var mu sync.Mutex
var cMap = map[digest.Digest]*v1.CacheChains{}

eg, ctx := errgroup.WithContext(ctx)
Expand Down Expand Up @@ -185,7 +187,9 @@ func (ci *contentCacheImporter) importInlineCache(ctx context.Context, dt []byte
if err := v1.ParseConfig(config, layers, cc); err != nil {
return err
}
mu.Lock()
cMap[dgst] = cc
mu.Unlock()
return nil
})
}(dgst, dt)
Expand Down

0 comments on commit be0d75f

Please sign in to comment.