frontend: fix two data races

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2018-07-10 19:31:33 -07:00
parent aee2723382
commit ddf3f3e59c
2 changed files with 7 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package dockerfile
import (
"context"
"sync"
"github.com/moby/buildkit/cache"
clienttypes "github.com/moby/buildkit/client"
@ -19,6 +20,7 @@ func llbBridgeToGatewayClient(ctx context.Context, llbBridge frontend.FrontendLL
type bridgeClient struct {
frontend.FrontendLLBBridge
mu sync.Mutex
opts map[string]string
final *ref
sid string
@ -38,6 +40,7 @@ func (c *bridgeClient) Solve(ctx context.Context, req client.SolveRequest, expor
return nil, err
}
rr := &ref{r}
c.mu.Lock()
c.refs = append(c.refs, rr)
if final {
c.final = rr
@ -49,6 +52,7 @@ func (c *bridgeClient) Solve(ctx context.Context, req client.SolveRequest, expor
}
c.exporterAttr = exporterAttr
}
c.mu.Unlock()
return rr, nil
}
func (c *bridgeClient) Opts() map[string]string {

View File

@ -51,8 +51,9 @@ func WithCacheSources(cms []solver.CacheManager) LoadOpt {
func RuntimePlatforms(p []specs.Platform) LoadOpt {
var defaultPlatform *pb.Platform
pp := make([]specs.Platform, len(p))
for i := range p {
p[i] = platforms.Normalize(p[i])
pp[i] = platforms.Normalize(p[i])
}
return func(op *pb.Op, _ *pb.OpMetadata, opt *solver.VertexOptions) error {
if op.Platform == nil {
@ -67,7 +68,7 @@ func RuntimePlatforms(p []specs.Platform) LoadOpt {
}
if _, ok := op.Op.(*pb.Op_Exec); ok {
var found bool
for _, pp := range p {
for _, pp := range pp {
if pp.OS == op.Platform.OS && pp.Architecture == op.Platform.Architecture && pp.Variant == op.Platform.Variant {
found = true
break