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

Maintenance: convert ICP HttpRequest* to smart Pointer #1804

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yadij
Copy link
Contributor

@yadij yadij commented Apr 28, 2024

No description provided.

@rousskov rousskov self-requested a review April 30, 2024 18:07
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.

@@ -136,19 +136,16 @@ icp_common_t::getOpCode() const

/* ICPState */

ICPState::ICPState(icp_common_t &aHeader, HttpRequest *aRequest):
ICPState::ICPState(icp_common_t &aHeader, const HttpRequestPointer &aRequest):
Copy link
Contributor

Choose a reason for hiding this comment

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

If you recall from previous discussions, I think we should use Foo::Pointer1 whenever that name has to be visible (for other valid reasons).

This suggestion illustrates the change but this change request applies to most other (if not all other) PR changes as well.

Suggested change
ICPState::ICPState(icp_common_t &aHeader, const HttpRequestPointer &aRequest):
ICPState::ICPState(icp_common_t &aHeader, const HttpRequest::Pointer &aRequest):

I do not insist on these changes.

Footnotes

  1. Instead of a FooPointer forward declaration.


/// \ingroup ServerProtocolICPAPI
bool icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request);
bool icpAccessAllowed(Ip::Address &, const HttpRequestPointer &);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep the first parameter name. It is very useful to a human reader of this declaration.

Suggested change
bool icpAccessAllowed(Ip::Address &, const HttpRequestPointer &);
bool icpAccessAllowed(Ip::Address &from, const HttpRequestPointer &);

{
int reason = refreshCheck(entry, request, 30);
int reason = refreshCheck(entry, request.getRaw(), 30);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
int reason = refreshCheck(entry, request.getRaw(), 30);
const auto reason = refreshCheck(entry, request.getRaw(), 30);

++ refreshCounts[rcICP].total;
++ refreshCounts[rcICP].status[reason];
return (reason < 200) ? 0 : 1;
return !(reason < 200);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are going to make this condition look different from its duplicates (in refresh.cc context), then please simplify it:

Suggested change
return !(reason < 200);
return reason >= 200;

Alternatively, keep the original look-and-feel (until all such conditions are fixed in refresh.cc):

Suggested change
return !(reason < 200);
return (reason < 200) ? false : true;

@@ -536,8 +529,6 @@ doV2Query(int fd, Ip::Address &from, char *buf, icp_common_t header)
}

icpCreateAndSend(codeToSend, flags, url, header.reqnum, src_rtt, fd, from, state.al);
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend removing "Maintenance: " from PR title because these changes might (positively) affect current or future code if, for example, icpCreateAndSend() throws. I do not insist on this change.

@rousskov rousskov added the S-waiting-for-author author action is expected (and usually required) label Apr 30, 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 May 2, 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 21, 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.

3 participants