-
Notifications
You must be signed in to change notification settings - Fork 3
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
Do not collapse ssl_crtd requests across reconfigurations 2 #228
base: master
Are you sure you want to change the base?
Do not collapse ssl_crtd requests across reconfigurations 2 #228
Conversation
In this new approach each Ssl::Helper object has its own GeneratorRequests map (used for collapsing). Since a reconfiguration creates a new Sll::Helper, the collapsed request are not shared across reconfigurations.
src/helper.cc
Outdated
@@ -132,7 +132,7 @@ HelperServerBase::dropQueued() | |||
void *cbdata; | |||
if (cbdataReferenceValidDone(r->request.data, &cbdata)) { | |||
r->reply.result = Helper::Unknown; | |||
r->request.callback(cbdata, r->reply); | |||
parentHelper()->callBack(r->request.callback, cbdata, r->reply); |
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.
Instead of adding a virtual parentHelper() -- a red flag for several reasons -- I would rather add a Helper::Client reference as a dropQueued() parameter.
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.
Done in PR229.
src/helper.cc
Outdated
result = Helper::Unknown; | ||
callback(data, Helper::Reply(Helper::Unknown)); | ||
} else { // pretend the helper has responded with ERR | ||
hlp->callBack(callback, data, Helper::Reply(Helper::Error)); |
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 do not send answers to never-submitted queries through the helper. Keep the old direct callback-calling code virtually unchanged here.
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.
Left this code as-is in PR229..
src/helper.cc
Outdated
@@ -576,6 +574,12 @@ helper::submit(const char *buf, HLPCB * callback, void *data) | |||
debugs(84, DBG_DATA, Raw("buf", buf, strlen(buf))); | |||
} | |||
|
|||
void | |||
helper::callBack(HLPCB *callback, void *data, const Helper::Reply &reply) |
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.
Most likely, this method should take just Xaction or Request+Reply parameters, not raw data+Reply.
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.
Without SubmissionFailure() changes, we do not need these parameters of course. In PR229, callBack() takes a single Xaction * argument.
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.
I found one problem that, if confirmed, will require refactoring and research. The rest is minor style polishing.
src/ssl/helper.h
Outdated
/** | ||
* Set of thread for ssl_crtd. This class is singleton. | ||
* This class use helper structure for threads management. | ||
*/ | ||
class Helper | ||
class Helper : public ::Helper::Client |
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 use this formatting variation for new and modified class declarations:
class Helper : public ::Helper::Client | |
class Helper: public ::Helper::Client |
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.
Done.
src/ssl/helper.h
Outdated
/// query:GeneratorRequest map | ||
using GeneratorRequests = std::unordered_map<SBuf, GeneratorRequest*>; | ||
|
||
explicit Helper(const char *name): Helper::Client(name) {} |
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.
explicit Helper(const char *name): Helper::Client(name) {} | |
explicit Helper(const char * const name): Helper::Client(name) {} |
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.
Done.
src/ssl/helper.h
Outdated
static Pointer Make(const char *name) { return new Helper(name); } | ||
|
||
/// pending Helper requests (to all certificate generator helpers combined) | ||
GeneratorRequests generatorRequests; |
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.
If possible, please make this and related type alias declaration private.
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.
Done.
and restored the (lost) removal of processed queries from generatorRequests map.
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.
Done (up to 98d2d9a).
src/ssl/helper.h
Outdated
/** | ||
* Set of thread for ssl_crtd. This class is singleton. | ||
* This class use helper structure for threads management. | ||
*/ | ||
class Helper | ||
class Helper : public ::Helper::Client |
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.
Done.
src/ssl/helper.h
Outdated
/// query:GeneratorRequest map | ||
using GeneratorRequests = std::unordered_map<SBuf, GeneratorRequest*>; | ||
|
||
explicit Helper(const char *name): Helper::Client(name) {} |
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.
Done.
src/ssl/helper.h
Outdated
static Pointer Make(const char *name) { return new Helper(name); } | ||
|
||
/// pending Helper requests (to all certificate generator helpers combined) | ||
GeneratorRequests generatorRequests; |
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.
Done.
Now it is unlocked before it gets deleted in Ssl::HandleGeneratorReply(). With the previous approach, it was unlocked in Helper::Request destructor after Ssl::HandleGeneratorReply() - the memory would not leak in this case. The updated callBack() looks more in line with the base Helper::Client::callBack().
We must remove GeneratorRequest object (and clear its generatorRequests map entry) if Helper::Client::trySubmit() returns an error or throws.
Temporalily added compiler '-H' option to figure out why sbuf/Algorithms.h is missed on the buildserver.
Squid collapses ssl_crtd requests on a pending request with an identical
helper query. This collapsing “works” across Squid reconfigurations even
though the old helper responsible for the first request is replaced with
a new one during reconfiguration; that old helper must complete
servicing pending requests.
However, since the helper program itself could have been changed (just
prior to reconfiguration), it is conceptually wrong for
post-reconfiguration requests to reuse the old helper program response:
Squid must conservatively assume that the response may have changed
because the helper protocol does not allow Squid to validate the
freshness of the helper response (to a collapsed request). Such blind
reuse also creates runtime problems if a buggy helper never responds to
a request X, stalling all the new requests getting collapsed on X (until
a Squid restart).
To avoid this post-reconfiguration collapsing, we now switch to a new
GeneratorRequests object during reconfiguration, instead of keeping
all collapsed requests in a global GeneratorRequests object.