Skip to content

Commit

Permalink
Merge pull request #498 from tonistiigi/race-fix
Browse files Browse the repository at this point in the history
frontend: fix two data races
  • Loading branch information
AkihiroSuda authored Jul 11, 2018
2 parents aee2723 + ddf3f3e commit c3846bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions frontend/dockerfile/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dockerfile

import (
"context"
"sync"

"github.com/moby/buildkit/cache"
clienttypes "github.com/moby/buildkit/client"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions solver/llbsolver/vertex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit c3846bd

Please sign in to comment.