Skip to content

Commit 1c17d98

Browse files
authored
Merge pull request moby#3940 from matiasinsaurralde/exec-process-server-send-lock
gateway: wrap ExecProcessServer Send calls with a mutex
2 parents 3c4e8f5 + 8a28fe6 commit 1c17d98

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

frontend/gateway/gateway.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,21 @@ func (w *outputWriter) Write(msg []byte) (int, error) {
11761176
return len(msg), stack.Enable(err)
11771177
}
11781178

1179+
type execProcessServerThreadSafe struct {
1180+
pb.LLBBridge_ExecProcessServer
1181+
sendMu sync.Mutex
1182+
}
1183+
1184+
func (w *execProcessServerThreadSafe) Send(m *pb.ExecMessage) error {
1185+
w.sendMu.Lock()
1186+
defer w.sendMu.Unlock()
1187+
return w.LLBBridge_ExecProcessServer.Send(m)
1188+
}
1189+
11791190
func (lbf *llbBridgeForwarder) ExecProcess(srv pb.LLBBridge_ExecProcessServer) error {
1191+
srv = &execProcessServerThreadSafe{
1192+
LLBBridge_ExecProcessServer: srv,
1193+
}
11801194
eg, ctx := errgroup.WithContext(srv.Context())
11811195

11821196
msgs := make(chan *pb.ExecMessage)

0 commit comments

Comments
 (0)