From b431277da850b47cd05c5e7697303c0d6fbe2cea Mon Sep 17 00:00:00 2001 From: Keiichi Hirobe Date: Tue, 28 Mar 2023 01:56:29 +0900 Subject: [PATCH] internal/singleflight: move Done call in TestForgetUnshared Prior to this change, there was a possibility that the call of ForgetUnshared at line 134 could acquire the lock first. Then, after ForgetUnshared released the lock, the doCall function could acquire it and complete its call. This change prevents this situation by ensuring that ForgetUnshared at line 134 only executes after doCall has finished executing and released the lock. Change-Id: I45cd4040e40ed52ca8e1b3863092886668dfd521 Reviewed-on: https://go-review.googlesource.com/c/go/+/479499 Reviewed-by: Matthew Dempsky Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- src/internal/singleflight/singleflight_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/singleflight/singleflight_test.go b/src/internal/singleflight/singleflight_test.go index a13893dd34..279e1beda1 100644 --- a/src/internal/singleflight/singleflight_test.go +++ b/src/internal/singleflight/singleflight_test.go @@ -100,9 +100,9 @@ func TestForgetUnshared(t *testing.T) { g.Do(key, func() (i interface{}, e error) { firstStarted.Done() <-firstCh - firstFinished.Done() return }) + firstFinished.Done() }() firstStarted.Wait() -- 2.50.0