Skip to content

Commit

Permalink
Add missing locks around broadcasts
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Gordon <[email protected]>
  • Loading branch information
msg authored and msg555 committed May 10, 2019
1 parent 646fc0a commit 78a8e64
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions control/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ func (gwf *GatewayForwarder) lookupForwarder(ctx context.Context) (gateway.LLBBr

go func() {
<-ctx.Done()
gwf.mu.Lock()
gwf.updateCond.Broadcast()
gwf.mu.Unlock()
}()

gwf.mu.RLock()
Expand Down
2 changes: 2 additions & 0 deletions session/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ func (sm *Manager) Get(ctx context.Context, id string) (Caller, error) {
go func() {
select {
case <-ctx.Done():
sm.mu.Lock()
sm.updateCondition.Broadcast()
sm.mu.Unlock()
}
}()

Expand Down
2 changes: 2 additions & 0 deletions solver/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ func (jl *Solver) Get(id string) (*Job, error) {

go func() {
<-ctx.Done()
jl.mu.Lock()
jl.updateCond.Broadcast()
jl.mu.Unlock()
}()

jl.mu.RLock()
Expand Down
4 changes: 4 additions & 0 deletions util/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ func (pr *progressReader) Read(ctx context.Context) ([]*Progress, error) {
select {
case <-done:
case <-ctx.Done():
pr.mu.Lock()
pr.cond.Broadcast()
pr.mu.Unlock()
}
}()
pr.mu.Lock()
Expand Down Expand Up @@ -163,7 +165,9 @@ func pipe() (*progressReader, *progressWriter, func()) {
pr.cond = sync.NewCond(&pr.mu)
go func() {
<-ctx.Done()
pr.mu.Lock()
pr.cond.Broadcast()
pr.mu.Unlock()
}()
pw := &progressWriter{
reader: pr,
Expand Down

0 comments on commit 78a8e64

Please sign in to comment.