aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/src/net_ssl.cpp
diff options
context:
space:
mode:
authorj-berman <justinberman@protonmail.com>2022-07-06 16:47:34 -0700
committerj-berman <justinberman@protonmail.com>2022-07-08 15:10:03 -0700
commita82fba4b7b944a54d2a14922f44d7eee367e4912 (patch)
tree6281ddd1008cbd92b421acc1c88cccdf3c8a60a7 /contrib/epee/src/net_ssl.cpp
parentconnection: fix implementation (diff)
downloadmonero-a82fba4b7b944a54d2a14922f44d7eee367e4912.tar.xz
address PR comments
Diffstat (limited to '')
-rw-r--r--contrib/epee/src/net_ssl.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/contrib/epee/src/net_ssl.cpp b/contrib/epee/src/net_ssl.cpp
index 7dda65bb5..2d0b7d791 100644
--- a/contrib/epee/src/net_ssl.cpp
+++ b/contrib/epee/src/net_ssl.cpp
@@ -553,9 +553,6 @@ bool ssl_options_t::handshake(
using ec_t = boost::system::error_code;
using timer_t = boost::asio::steady_timer;
using strand_t = boost::asio::io_service::strand;
- using lock_t = std::mutex;
- using lock_guard_t = std::lock_guard<lock_t>;
- using condition_t = std::condition_variable_any;
using socket_t = boost::asio::ip::tcp::socket;
auto &io_context = GET_IO_SERVICE(socket);
@@ -565,8 +562,8 @@ bool ssl_options_t::handshake(
timer_t deadline(io_context, timeout);
struct state_t {
- lock_t lock;
- condition_t condition;
+ std::mutex lock;
+ std::condition_variable_any condition;
ec_t result;
bool wait_timer;
bool wait_handshake;
@@ -577,10 +574,10 @@ bool ssl_options_t::handshake(
state.wait_timer = true;
auto on_timer = [&](const ec_t &ec){
- lock_guard_t guard(state.lock);
+ std::lock_guard<std::mutex> guard(state.lock);
state.wait_timer = false;
state.condition.notify_all();
- if (not state.cancel_timer) {
+ if (!state.cancel_timer) {
state.cancel_handshake = true;
ec_t ec;
socket.next_layer().cancel(ec);
@@ -589,11 +586,11 @@ bool ssl_options_t::handshake(
state.wait_handshake = true;
auto on_handshake = [&](const ec_t &ec, size_t bytes_transferred){
- lock_guard_t guard(state.lock);
+ std::lock_guard<std::mutex> guard(state.lock);
state.wait_handshake = false;
state.condition.notify_all();
state.result = ec;
- if (not state.cancel_handshake) {
+ if (!state.cancel_handshake) {
state.cancel_timer = true;
ec_t ec;
deadline.cancel(ec);
@@ -614,15 +611,15 @@ bool ssl_options_t::handshake(
while (!io_context.stopped())
{
io_context.poll_one();
- lock_guard_t guard(state.lock);
+ std::lock_guard<std::mutex> guard(state.lock);
state.condition.wait_for(
state.lock,
std::chrono::milliseconds(30),
[&]{
- return not state.wait_timer and not state.wait_handshake;
+ return !state.wait_timer && !state.wait_handshake;
}
);
- if (not state.wait_timer and not state.wait_handshake)
+ if (!state.wait_timer && !state.wait_handshake)
break;
}
if (state.result.value()) {