diff options
author | Gaurav Singh <gaurav1086@gmail.com> | 2020-07-23 23:27:05 +0000 |
---|---|---|
committer | Emmanuel Odeke <emm.odeke@gmail.com> | 2020-08-14 23:04:16 +0000 |
commit | 5a18e0b58ca2d08f3988018a8759207cb64e651a (patch) | |
tree | 9bb3d2529701a4d0c35da93d6acc3f48e83f88d6 /src/sync | |
parent | 24ff2af65e27eed1e8c7f09c21a5ca68fc2e07ab (diff) | |
download | go-5a18e0b58ca2d08f3988018a8759207cb64e651a.tar.gz go-5a18e0b58ca2d08f3988018a8759207cb64e651a.zip |
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: a7d811a7be6d875175a894e53d474aa0034e7d2c
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>
Diffstat (limited to 'src/sync')
-rw-r--r-- | src/sync/mutex_test.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/sync/mutex_test.go b/src/sync/mutex_test.go index e61a853642..98c1bf2a5f 100644 --- a/src/sync/mutex_test.go +++ b/src/sync/mutex_test.go @@ -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) |