Repository navigation
netcore: configure requests to cancel on drop - #466
Merged
Merged
Conversation
npry
force-pushed
the
npry/netcore.abort-on-drop
branch
4 times, most recently
from
October 29, 2026 14:14
8e1afa8 to
57392f0
Compare
nrc
approved these changes
Nov 3, 2026
nrc
left a comment
Contributor
There was a problem hiding this comment.
Looks good, one minor and not-strongly-held comment
npry
force-pushed
the
npry/netcore.abort-on-drop
branch
2 times, most recently
from
November 3, 2026 21:11
eef78f4 to
c0eb6c3
Compare
Per #447, netstack futures weren't cancel safe because we wouldn't check if the response channel was closed when processing the command. As a result, socket operations which were part of canceled futures would previously always complete, potentially throwing away received packets or accepts, or resending outgoing sends (all modulo caller logic, but this would be common in a `select!` loop, especially with timers involved). This hadn't been resolved previously because netsock specifically depends on this behavior to ensure delivery of `Close` commands on socket drop without having to wait for a response. Resolved by adding a flag to `Request` indicating the desired behavior (only nonblocking requests complete regardless of response channel, state, while normal requests give up before trying to process the command). There is still a possible race if the caller drops the channel after we've started processing the command, but this isn't resolvable without implementing rollback in order to revert a command if it turns out the response couldn't be delivered, which seems more trouble than it's worth. Closes #447 Signed-off-by: Nathan Perry <nathan@tailscale.com> Change-Id: I071e8acce05fd9cc4fe3eb6cabdb9a6f6a6a6964
npry
force-pushed
the
npry/netcore.abort-on-drop
branch
from
November 3, 2026 21:13
c0eb6c3 to
9f7cec0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per #447, netstack futures weren't cancel safe because we wouldn't check if the response channel was closed when processing the command. As a result, socket operations which were part of canceled futures would always complete, potentially throwing away received packets or accepts, or resending outgoing sends (all modulo caller logic, but this would be common in a
select!loop).This hadn't been resolved previously because netsock specifically depends on this behavior to ensure delivery of
Closecommands on socket drop without having to wait for a response.Resolved by adding a flag to
Requestindicating the desired behavior (only nonblocking requests complete regardless of response channel state, while normal requests give up before trying to process the command). There is still a possible race if the caller drops the channel after we've started processing the command, but this isn't resolvable without implementing command rollback (i.e. to revert a command if it turns out the response couldn't be delivered, which seems more trouble than it's worth).Closes #447