Skip to content

Commit

Permalink
Fix data race in asio service (#556)
Browse files Browse the repository at this point in the history
Co-authored-by: Jung-Sang Ahn <[email protected]>
  • Loading branch information
antonio2368 and greensky00 authored Dec 4, 2024
1 parent 149cd03 commit 50e2f94
Showing 1 changed file with 9 additions and 9 deletions.
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

0 comments on commit 50e2f94

Please sign in to comment.