Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(449)

Unified Diff: src/cmd/go/build.go

Issue 6943043: cmd/go: unblock all workers on signal (Closed)
Patch Set: diff -r 3fe40a41018d https://code.google.com/p/go Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/cmd/go/signal.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cmd/go/build.go
===================================================================
--- a/src/cmd/go/build.go
+++ b/src/cmd/go/build.go
@@ -548,7 +548,6 @@
}
b.readySema = make(chan bool, len(all))
- done := make(chan bool)
// Initialize per-action execution state.
for _, a := range all {
@@ -596,10 +595,11 @@
if a == root {
close(b.readySema)
- done <- true
}
}
+ var wg sync.WaitGroup
+
// Kick off goroutines according to parallelism.
// If we are using the -n flag (just printing commands)
// drop the parallelism to 1, both to make the output
@@ -609,19 +609,30 @@
par = 1
}
for i := 0; i < par; i++ {
+ wg.Add(1)
go func() {
- for _ = range b.readySema {
- // Receiving a value from b.sema entitles
- // us to take from the ready queue.
- b.exec.Lock()
- a := b.ready.pop()
- b.exec.Unlock()
- handle(a)
+ defer wg.Done()
+ for {
+ select {
+ case _, ok := <-b.readySema:
+ if !ok {
+ return
+ }
+ // Receiving a value from b.readySema entitles
+ // us to take from the ready queue.
+ b.exec.Lock()
+ a := b.ready.pop()
+ b.exec.Unlock()
+ handle(a)
+ case <-interrupted:
+ setExitStatus(1)
+ return
+ }
}
}()
}
- <-done
+ wg.Wait()
}
// build is the action for building a single package or command.
« no previous file with comments | « no previous file | src/cmd/go/signal.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b