-
Notifications
You must be signed in to change notification settings - Fork 760
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
we might have a HostEntry in the dns cache already #11126
base: master
Are you sure you want to change the base?
Conversation
4b9822a
to
ff75c93
Compare
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.
Thanks, @caolanm. I like the direction, but have concerns with switching the callback. I think we should work towards a better design that handles this case seamlessly.
net/HttpRequest.hpp
Outdated
} | ||
|
||
poller.insertNewSocket(socket); | ||
origOnConnectFail(rSession); |
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.
We should check that origOnConnectFail
is valid. There is no guarantee that it is.
net/HttpRequest.hpp
Outdated
{ | ||
// Intercept onConnectFail to detect connection failure, call the original (if any), | ||
// and finish the response to end the poller loop. | ||
setConnectFailHandler([this, origOnConnectFail](const std::shared_ptr<http::Session>& rSession) { |
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 we have to do this, something is likely wrong with the design. (Also see below.)
If we need this to call _response->finish();
, then the question is: why isn't it called when the connection fails anyway?
I think we should call onDisconnect()
(or its equivalent) from callOnConnectFail()
.
The original design is to always call the 'onFinished' handler. We promise this for the setFinishedHandler()
:
/// Set a callback to handle onFinished events from this session.
/// onFinished is triggered whenever a request has finished,
/// regardless of the reason (error, timeout, completion).
void setFinishedHandler(FinishedCallback onFinished) { _onFinished = std::move(onFinished); }
So it's a good idea to do so when we fail to connect as well. We can extend the Response::State
enum to include ConnectionError
(we can rename the current Error
to ProtocolError
), and always invoke the same onDisconnect()
and onFinished
, to let the client do whatever cleanup and/or continuation.
(I'm not sure we ever needed a 'connectFailHandler', as such, rather than AsyncConnectResult
+ onFinished. Perhaps what's missing is the new State above?)
net/HttpRequest.hpp
Outdated
|
||
const auto remaining = | ||
std::chrono::duration_cast<std::chrono::microseconds>(deadline - now); | ||
poller.poll(remaining); | ||
} | ||
|
||
setConnectFailHandler(origOnConnectFail); |
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 isn't exception-safe. Yet another problem with the need to switch handlers, which we should avoid by having a more homogeneous design.
My assumption here with "routing syncRequestImpl connect through asyncDNS" was that the remaining "sync" dns use in wsd/Storage.cpp StorageBase::validate might be amenable to being split up into something where the result in an async callback would be usable so all the remaining sync DNS uses could be dropped. That looks plausible for the uses in wsd/RequestVettingStation.cpp and wsd/wopi/WopiProxy.cpp, but the StorageBase::create use of validate looks much more uncertain to achieve successfully. Trying an alternative approach of passing a HostEntry to "validate" and bubbling that down from the initial places the uri can come from becomes unwieldy pretty fast and terminates in a bunch of places where have the same issue. So lets try another alternative. |
Signed-off-by: Caolán McNamara <[email protected]> Change-Id: I2a08bd77f837ba3b8a2a57e90e79ce5bb86305e8
9bc06b5
to
349e6ac
Compare
so can cache regardless of port, and apply the port when needed to a copy of the result Signed-off-by: Caolán McNamara <[email protected]> Change-Id: I8142b16dec85a3cca3d0c1acc1467accd0aab671
so we have a single cache of DNS results. Signed-off-by: Caolán McNamara <[email protected]> Change-Id: I72f39ddaa1badb245f7e04c6f9c6b4c8d20f67fc
349e6ac
to
0f15681
Compare
Change-Id: I2a08bd77f837ba3b8a2a57e90e79ce5bb86305e8
Summary
TODO
Checklist
make prettier-write
and formatted the code.make check
make run
and manually verified that everything looks okay