Fix goroutine leak in deadline If the deadline timed out then the worker goroutine might have been leaked trying to write to `result` which had no readers.
Evan Huus
4 years ago
1 changed file(s) with
5 addition(s)
and
1 deletion(s)
.
Raw diff
Collapse all
Expand all
+5
-1
deadline/deadline.go
less
more
31
31
stopper := make(chan struct{})
32
32
33
33
go func() {
34
result <- work(stopper)
34
value := work(stopper)
35
select {
36
case result <- value:
37
case <-stopper:
38
}
35
39
}()
36
40
37
41
select {