Skip to content

Commit 8fcdb60

Browse files
cuonglmgopherbot
authored andcommitted
singleflight: avoid race between multiple Do calls
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]>
1 parent 7f9b162 commit 8fcdb60

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

singleflight/singleflight.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ func (g *Group) doCall(c *call, key string, fn func() (interface{}, error)) {
144144
c.err = errGoexit
145145
}
146146

147-
c.wg.Done()
148147
g.mu.Lock()
149148
defer g.mu.Unlock()
149+
c.wg.Done()
150150
if g.m[key] == c {
151151
delete(g.m, key)
152152
}

0 commit comments

Comments
 (0)