Skip to content
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
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yadij
Copy link
Contributor

@yadij yadij commented Jun 29, 2024

Refactor to avoid storing a raw-pointer, with
missing reference-counting.

@kinkie
Copy link
Contributor

kinkie commented Jun 29, 2024

This PR seems to contain spurious changes

@rousskov rousskov self-requested a review June 29, 2024 12:33
@rousskov rousskov changed the title Update Http::Stream::reply to Pointer Upgrade Http::Stream::reply to Pointer Jun 29, 2024
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this upgrade.

I replaced "update" with "upgrade" in PR title because the latter feels more precise and arguably self-documents the motivation behind this PR. Please undo if you think "update" is better.

src/http/Stream.cc Outdated Show resolved Hide resolved
src/http/Stream.cc Outdated Show resolved Hide resolved
src/http/Stream.cc Outdated Show resolved Hide resolved
src/http/Stream.cc Show resolved Hide resolved
src/http/Stream.cc Show resolved Hide resolved
@rousskov rousskov added the S-waiting-for-author author action is expected (and usually required) label Jun 29, 2024
@squid-anubis squid-anubis added M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels and removed M-failed-other https://github.com/measurement-factory/anubis#pull-request-labels labels Aug 20, 2024
Refactor to avoid storing a raw-pointer, with
missing reference-counting.
@yadij
Copy link
Contributor Author

yadij commented Nov 16, 2024

Rebased on master without ESI and related callback complications.

@yadij yadij added S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box and removed S-waiting-for-author author action is expected (and usually required) labels Nov 16, 2024
@yadij yadij requested a review from rousskov November 16, 2024 09:49
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for advancing this PR. I am glad ESI removal also helped with this PR! I only have a few small change requests left.

@@ -377,7 +379,7 @@ Http::Stream::noteSentBodyBytes(size_t bytes)

/// \return true when If-Range specs match reply, false otherwise
static bool
clientIfRangeMatch(ClientHttpRequest * http, HttpReply * rep)
clientIfRangeMatch(ClientHttpRequest * http, const HttpReplyPointer &reply)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's replace this unchecked/unwanted pointer with a reference instead of just changing its type:

Suggested change
clientIfRangeMatch(ClientHttpRequest * http, const HttpReplyPointer &reply)
clientIfRangeMatch(ClientHttpRequest * http, const HttpReply &reply)

... and adjust the function caller and pointer user accordingly.

The above will not make existing diff larger (because all these lines have to be changed anyway) but will improve code.

@@ -387,7 +389,7 @@ clientIfRangeMatch(ClientHttpRequest * http, HttpReply * rep)

/* got an ETag? */
if (spec.tag.str) {
ETag rep_tag = rep->header.getETag(Http::HdrType::ETAG);
ETag rep_tag = reply->header.getETag(Http::HdrType::ETAG);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible:

Suggested change
ETag rep_tag = reply->header.getETag(Http::HdrType::ETAG);
const auto rep_tag = reply.header.getETag(Http::HdrType::ETAG);

Otherwise:

Suggested change
ETag rep_tag = reply->header.getETag(Http::HdrType::ETAG);
auto rep_tag = reply.header.getETag(Http::HdrType::ETAG);

The above suggestions account for another change request that replaces an unchecked pointer with a reference (but its essence is unrelated to that change request).

range_err = "If-Range match failed";

else if (!http->request->range->canonize(rep))
else if (!http->request->range->canonize(reply.getRaw()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the only canonize() caller that supplies a pointer, please upgrade the corresponding canonize() method to take a reference instead of a pointer. The method already asserts that the pointer is not nil.

Suggested change
else if (!http->request->range->canonize(reply.getRaw()))
else if (!http->request->range->canonize(*reply))

@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-for-author author action is expected (and usually required)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants