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

Fix data race in asio service #556

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 9 additions & 9 deletions src/asio_service.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,15 @@ class asio_rpc_client
asio::ip::tcp::resolver::iterator itor ) -> void
{
if (!err) {
if (send_timeout_ms != 0) {
operation_timer_.expires_after
( std::chrono::duration_cast<std::chrono::nanoseconds>
( std::chrono::milliseconds( send_timeout_ms ) ) );
operation_timer_.async_wait(
std::bind( &asio_rpc_client::cancel_socket,
this,
std::placeholders::_1 ) );
}
asio::async_connect
( socket(),
itor,
Expand All @@ -1472,15 +1481,6 @@ class asio_rpc_client
send_timeout_ms,
std::placeholders::_1,
std::placeholders::_2 ) );
if (send_timeout_ms != 0) {
operation_timer_.expires_after
( std::chrono::duration_cast<std::chrono::nanoseconds>
( std::chrono::milliseconds( send_timeout_ms ) ) );
operation_timer_.async_wait(
std::bind( &asio_rpc_client::cancel_socket,
this,
std::placeholders::_1 ) );
}
} else {
std::string err_msg = lstrfmt("failed to resolve host %s "
"due to error %d, %s")
Expand Down
Loading