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

[5.0] PH: Post on resolver strand to ensure execution on strand #1863

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/trx_generator/http_client_async.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ class session : public std::enable_shared_from_this<session> {
req_.prepare_payload();

// Look up the domain name
resolver_.async_resolve(
host, std::to_string(port), [self = this->shared_from_this()](beast::error_code ec, auto res) { self->on_resolve(ec, res); });
boost::asio::post( resolver_.get_executor(), [host, port, self=this->shared_from_this()] {
self->resolver_.async_resolve(
host, std::to_string(port), [self](beast::error_code ec, auto res) { self->on_resolve(ec, res); });
});
Comment on lines +83 to +86
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this change make a difference? I would have thought that, since we provide an executor when building the resolver, the async functions would already be posted on this executor?

Copy link
Member Author

Choose a reason for hiding this comment

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

This code follows the example of libs/beast/example/http/client/async/http_client_async.cpp however I think it would be better to follow https://www.boost.org/doc/libs/1_83_0/libs/beast/example/http/client/crawl/http_crawl.cpp as that is a multi-threaded example. I'll close this PR and create a new one with those changes.

}

void on_resolve(beast::error_code ec, tcp::resolver::results_type results) {
Expand Down