From f1055ead9fcdf151c14f749195212ace6b1b8aad Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Wed, 9 Oct 2019 13:49:43 +0300 Subject: [PATCH 1/3] try Instant fix in SS --- secret-store/src/key_server_cluster/cluster_connections_net.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/secret-store/src/key_server_cluster/cluster_connections_net.rs b/secret-store/src/key_server_cluster/cluster_connections_net.rs index 75c0a36fa9d..d13980f338a 100644 --- a/secret-store/src/key_server_cluster/cluster_connections_net.rs +++ b/secret-store/src/key_server_cluster/cluster_connections_net.rs @@ -467,10 +467,9 @@ fn net_maintain(data: Arc) { /// Send keep alive messages to remote nodes. fn net_keep_alive(data: Arc) { - let now = Instant::now(); let active_connections = data.active_connections(); for connection in active_connections { - let last_message_diff = now - connection.last_message_time(); + let last_message_diff = Instant::now() - connection.last_message_time(); if last_message_diff > KEEP_ALIVE_DISCONNECT_INTERVAL { warn!(target: "secretstore_net", "{}: keep alive timeout for node {}", data.self_key_pair.public(), connection.node_id()); From a7f0a4eeefe5fd5021b8673be1c6c9ba5c69d313 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Thu, 10 Oct 2019 10:29:12 +0300 Subject: [PATCH 2/3] proper fix + add comment --- .../src/key_server_cluster/cluster_connections_net.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/secret-store/src/key_server_cluster/cluster_connections_net.rs b/secret-store/src/key_server_cluster/cluster_connections_net.rs index d13980f338a..dff426e42cc 100644 --- a/secret-store/src/key_server_cluster/cluster_connections_net.rs +++ b/secret-store/src/key_server_cluster/cluster_connections_net.rs @@ -469,7 +469,11 @@ fn net_maintain(data: Arc) { fn net_keep_alive(data: Arc) { let active_connections = data.active_connections(); for connection in active_connections { - let last_message_diff = Instant::now() - connection.last_message_time(); + // the last_message_time could change after active_connections() call + // => we always need to call Instant::now() after getting last_message_time + let last_message_time = connection.last_message_time() + let now = Instant::now(); + let last_message_diff = now - last_message_time; if last_message_diff > KEEP_ALIVE_DISCONNECT_INTERVAL { warn!(target: "secretstore_net", "{}: keep alive timeout for node {}", data.self_key_pair.public(), connection.node_id()); From 85ca659c350499137cb6d9c2fa9e3265dbd050aa Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Thu, 10 Oct 2019 10:45:29 +0300 Subject: [PATCH 3/3] fix compilation --- secret-store/src/key_server_cluster/cluster_connections_net.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/secret-store/src/key_server_cluster/cluster_connections_net.rs b/secret-store/src/key_server_cluster/cluster_connections_net.rs index dff426e42cc..155c0604d23 100644 --- a/secret-store/src/key_server_cluster/cluster_connections_net.rs +++ b/secret-store/src/key_server_cluster/cluster_connections_net.rs @@ -471,7 +471,7 @@ fn net_keep_alive(data: Arc) { for connection in active_connections { // the last_message_time could change after active_connections() call // => we always need to call Instant::now() after getting last_message_time - let last_message_time = connection.last_message_time() + let last_message_time = connection.last_message_time(); let now = Instant::now(); let last_message_diff = now - last_message_time; if last_message_diff > KEEP_ALIVE_DISCONNECT_INTERVAL {