Skip to content

Commit

Permalink
singleflight: avoid race between multiple Do calls
Browse files Browse the repository at this point in the history
This is port of CL 436437, but without the test. ForgotUnshared has not
been ported here yet.

Change-Id: Id54d0c41d1a7948bf008e458c44b21670ada81e4
Reviewed-on: https://go-review.googlesource.com/c/sync/+/436495
Run-TryBot: Cuong Manh Le <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Auto-Submit: Cuong Manh Le <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
  • Loading branch information
cuonglm authored and gopherbot committed Sep 29, 2022
1 parent 7f9b162 commit 8fcdb60
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion singleflight/singleflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ func (g *Group) doCall(c *call, key string, fn func() (interface{}, error)) {
c.err = errGoexit
}

c.wg.Done()
g.mu.Lock()
defer g.mu.Unlock()
c.wg.Done()
if g.m[key] == c {
delete(g.m, key)
}
Expand Down

0 comments on commit 8fcdb60

Please sign in to comment.