-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade Http::Stream::reply to Pointer #1855
Open
yadij
wants to merge
6
commits into
squid-cache:master
Choose a base branch
from
yadij:arc-http-ng-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+115
−127
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
84cf58a
Update Http::Stream::reply to Pointer
yadij 3a3d58b
Apply suggestions from code review
yadij 8453b24
Update Stream.cc
yadij d0c9084
Merge branch 'master' into arc-http-ng-2
yadij 9fd23e1
Upgrade Http::Stream::DeferredParams::reply as well
yadij 7516249
Down the rabbit-hole of DeferredParams clientStreams
yadij File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
This HttpReply object may be passed from its raw/unprotected/lockless DeferredParams::reply storage to now-refconted Http::Stream::reply storage. I hope those deferred parameters always belong to the same Http::Stream object, but if they are not, then Http::Stream::reply object might be destroyed (via now-added Http::Stream::reply reference counting) before the corresponding DeferredParams object is destroyed, creating a dangling pointer inside DeferredParams storage. I recommend upgrading Http::Stream::DeferredParams::reply together with Http::Stream::reply (i.e. in this PR) to mitigate that risk.
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.
Looking at branch commit 7516249 (and, to a degree, its parent), it feels like something went wrong while upgrading Http::Stream::DeferredParams::reply storage. If possible, please avoid changing all (or the vast majority of) those functions! During these transitions, it is OK to pass a raw pointer (to a reference-counted HttpReply object) to legacy code that does not store that pointer or stores it properly. AFAICT, most of those modified functions fall into the former category. They should not be modified.
If there are some problems with that approach, let's discuss.
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.
There is a chain reaction going on here. This is as small a chain of side effects as I can make it.
A) To fix the dangling pointer in
Http::Stream::DeferredParams::reply
updateHttp::Stream::DeferredParams::reply
to RefCount.That pushes the dangling pointer problem into ESIIncludeContext and Downloader where class methods using
CSCB
type for AsyncCall parameters as a raw-pointer (now the dangling one).B) To fix (A) update
CSCB
definition to pass RefCount instead. Which pulls in all theCSCB
functions.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.
Thank you for detailing this! I hope we can find a way to stop that chain reaction much sooner than branch commit 7516249 does:
CSCB callbacks are synchronous, right? When I look at Downloader changes in branch commit 7516249, I do not see any long-term HttpReply storage. I only see caller's reply pointer being forwarded to another synchronous call. That kind of forwarding, by itself, does not require smart pointers and does not create dangling raw pointers. Let's temporary assume, to simplify arguments, that downloaderRecipient() is the only CSCB callback in existence. Why do we have to change downloaderRecipient() and CSCB type after changing Http::Stream::DeferredParams::reply?