Light Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

util/singleflight remove map for prevent subsequent callers joining an already-canceled call#18924

Open
moodTRBL wants to merge 3 commits intotailscale:mainfrom
moodTRBL:moodtrbl/early-map-remove
Open

util/singleflight remove map for prevent subsequent callers joining an already-canceled call#18924
moodTRBL wants to merge 3 commits intotailscale:mainfrom
moodTRBL:moodtrbl/early-map-remove

Conversation

Copy link

moodTRBL commented Mar 9, 2026

Prevents subsequent callers joining an already-canceled call.

Fixes: #18919

Copy link

chatgpt-codex-connector bot left a 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".

Comment on lines +230 to +231
if g.m[key] == c {
delete(g.m, key)
Copy link

chatgpt-codex-connector bot Mar 9, 2026

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 / .

moodTRBL changed the title Moodtrbl/early map remove for prevent subsequent callers joining an already-canceled call util/singleflight map remove for prevent subsequent callers joining an already-canceled call Mar 9, 2026
moodTRBL changed the title util/singleflight map remove for prevent subsequent callers joining an already-canceled call util/singleflight remove map for prevent subsequent callers joining an already-canceled call Mar 9, 2026
moodTRBL added 3 commits March 9, 2026 18:12
moodTRBL force-pushed the moodtrbl/early-map-remove branch from a7e754a to 161ec39 Compare March 9, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

util/singleflight: DoChanContext can cause unrelated requests to be canceled

1 participant