-
Notifications
You must be signed in to change notification settings - Fork 528
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
I do not insist on these changes. Footnotes
|
||||||
header(aHeader), | ||||||
request(aRequest), | ||||||
fd(-1), | ||||||
url(nullptr) | ||||||
{ | ||||||
HTTPMSGLOCK(request); | ||||||
} | ||||||
{} | ||||||
|
||||||
ICPState::~ICPState() | ||||||
{ | ||||||
safe_free(url); | ||||||
HTTPMSGUNLOCK(request); | ||||||
} | ||||||
|
||||||
bool | ||||||
|
@@ -191,7 +188,7 @@ ICPState::loggingTags() const | |||||
void | ||||||
ICPState::fillChecklist(ACLFilledChecklist &checklist) const | ||||||
{ | ||||||
checklist.setRequest(request); | ||||||
checklist.setRequest(request.getRaw()); | ||||||
icpSyncAle(al, from, url, 0, 0); | ||||||
checklist.al = al; | ||||||
} | ||||||
|
@@ -205,7 +202,7 @@ class ICP2State: public ICPState | |||||
{ | ||||||
|
||||||
public: | ||||||
ICP2State(icp_common_t & aHeader, HttpRequest *aRequest): | ||||||
ICP2State(icp_common_t & aHeader, const HttpRequestPointer &aRequest): | ||||||
ICPState(aHeader, aRequest),rtt(0),src_rtt(0),flags(0) {} | ||||||
|
||||||
~ICP2State() override; | ||||||
|
@@ -439,14 +436,14 @@ icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd) | |||||
} | ||||||
|
||||||
bool | ||||||
icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request) | ||||||
icpAccessAllowed(Ip::Address &from, const HttpRequestPointer &icp_request) | ||||||
{ | ||||||
if (!Config.accessList.icp) { | ||||||
debugs(12, 2, "Access Denied due to lack of ICP access rules."); | ||||||
return false; | ||||||
} | ||||||
|
||||||
ACLFilledChecklist checklist(Config.accessList.icp, icp_request, nullptr); | ||||||
ACLFilledChecklist checklist(Config.accessList.icp, icp_request.getRaw(), nullptr); | ||||||
checklist.src_addr = from; | ||||||
checklist.my_addr.setNoAddr(); | ||||||
const auto &answer = checklist.fastCheck(); | ||||||
|
@@ -457,7 +454,7 @@ icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request) | |||||
return false; | ||||||
} | ||||||
|
||||||
HttpRequest * | ||||||
HttpRequestPointer | ||||||
icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from) | ||||||
{ | ||||||
if (strpbrk(url, w_space)) { | ||||||
|
@@ -467,12 +464,11 @@ icpGetRequest(char *url, int reqnum, int fd, Ip::Address &from) | |||||
} | ||||||
|
||||||
const auto mx = MasterXaction::MakePortless<XactionInitiator::initIcp>(); | ||||||
auto *result = HttpRequest::FromUrlXXX(url, mx); | ||||||
HttpRequestPointer result = HttpRequest::FromUrlXXX(url, mx); | ||||||
if (!result) | ||||||
icpCreateAndSend(ICP_ERR, 0, url, reqnum, 0, fd, from, nullptr); | ||||||
|
||||||
return result; | ||||||
|
||||||
} | ||||||
|
||||||
static void | ||||||
|
@@ -483,16 +479,13 @@ doV2Query(int fd, Ip::Address &from, char *buf, icp_common_t header) | |||||
uint32_t flags = 0; | ||||||
/* We have a valid packet */ | ||||||
char *url = buf + sizeof(icp_common_t) + sizeof(uint32_t); | ||||||
HttpRequest *icp_request = icpGetRequest(url, header.reqnum, fd, from); | ||||||
const auto icp_request = icpGetRequest(url, header.reqnum, fd, from); | ||||||
|
||||||
if (!icp_request) | ||||||
return; | ||||||
|
||||||
HTTPMSGLOCK(icp_request); | ||||||
|
||||||
if (!icpAccessAllowed(from, icp_request)) { | ||||||
icpDenyAccess(from, url, header.reqnum, fd); | ||||||
HTTPMSGUNLOCK(icp_request); | ||||||
return; | ||||||
} | ||||||
#if USE_ICMP | ||||||
|
@@ -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); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
|
||||||
HTTPMSGUNLOCK(icp_request); | ||||||
} | ||||||
|
||||||
void | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -579,13 +579,13 @@ refreshCheckHTTP(const StoreEntry * entry, HttpRequest * request) | |||||||||
} | ||||||||||
|
||||||||||
/// \see int refreshCheckHTTP(const StoreEntry * entry, HttpRequest * request) | ||||||||||
int | ||||||||||
refreshCheckICP(const StoreEntry * entry, HttpRequest * request) | ||||||||||
bool | ||||||||||
refreshCheckICP(const StoreEntry *entry, const HttpRequestPointer &request) | ||||||||||
{ | ||||||||||
int reason = refreshCheck(entry, request, 30); | ||||||||||
int reason = refreshCheck(entry, request.getRaw(), 30); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
++ refreshCounts[rcICP].total; | ||||||||||
++ refreshCounts[rcICP].status[reason]; | ||||||||||
return (reason < 200) ? 0 : 1; | ||||||||||
return !(reason < 200); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Alternatively, keep the original look-and-feel (until all such conditions are fixed in refresh.cc):
Suggested change
|
||||||||||
} | ||||||||||
|
||||||||||
#if USE_HTCP | ||||||||||
|
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.
Please keep the first parameter name. It is very useful to a human reader of this declaration.