-
Notifications
You must be signed in to change notification settings - Fork 2.4k
util/singleflight remove map for prevent subsequent callers joining an already-canceled call#18924
util/singleflight remove map for prevent subsequent callers joining an already-canceled call#18924moodTRBL wants to merge 3 commits intotailscale:mainfrom
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a7e754ad40
i About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with .
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if g.m[key] == c { | ||
| delete(g.m, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard early map deletion with waiter count under mutex
Deleting g.m[key] here can race with a new DoChanContext caller: after ctxWaiters.Add(-1) == 0 but before this lock, a new caller can grab g.mu, find c in the map, increment ctxWaiters, and attach to the already-canceled call; this block then still deletes the entry because g.m[key] == c, allowing subsequent callers to start a second in-flight call for the same key while the first is still running. That breaks singleflight deduplication and is introduced by the new early-delete path.
Useful? React with / .
a7e754a to
161ec39
Compare