mirror of
https://github.com/golang/go
synced 2024-11-17 16:54:44 -07:00
sync: fix goroutine leak for when TestMutexFairness times out
If the timeout triggers before writing to the done channel, the
goroutine will be blocked waiting for a corresponding read that’s
no longer existent, thus a goroutine leak. This change fixes that by
using a buffered channel instead.
Change-Id: I9cf4067a58bc5a729ab31e4426edd78bd359e8e0
GitHub-Last-Rev: a7d811a7be
GitHub-Pull-Request: golang/go#40236
Reviewed-on: https://go-review.googlesource.com/c/go/+/242902
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
24ff2af65e
commit
5a18e0b58c
@ -194,7 +194,7 @@ func TestMutexFairness(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}()
|
||||
done := make(chan bool)
|
||||
done := make(chan bool, 1)
|
||||
go func() {
|
||||
for i := 0; i < 10; i++ {
|
||||
time.Sleep(100 * time.Microsecond)
|
||||
|
Loading…
Reference in New Issue
Block a user