]> Cypherpunks repositories - gostls13.git/commitdiff
internal/singleflight: move Done call in TestForgetUnshared
authorKeiichi Hirobe <chalenge.akane@gmail.com>
Mon, 27 Mar 2023 16:56:29 +0000 (01:56 +0900)
committerGopher Robot <gobot@golang.org>
Wed, 29 Mar 2023 22:21:50 +0000 (22:21 +0000)
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 <mdempsky@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/internal/singleflight/singleflight_test.go

index a13893dd34af5e983227815b432f57d9bfd76f11..279e1beda1be729d3a6ef27dbf9e32587ba246b5 100644 (file)
@@ -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()