From 508fa6a7fed894fd616239c04aeb0c2e8f6b9022 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 25 Oct 2017 15:44:10 -0700 Subject: A few fixes for cluster mode. --- node/Path.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'node/Path.hpp') diff --git a/node/Path.hpp b/node/Path.hpp index 80132c13..ab52ced6 100644 --- a/node/Path.hpp +++ b/node/Path.hpp @@ -281,13 +281,18 @@ public: /** * @return Path quality -- lower is better */ - inline int quality(const int64_t now) const + inline long quality(const int64_t now) const { - const int l = (int)_latency; - const int age = (int)std::min((now - _lastIn),(int64_t)(ZT_PATH_HEARTBEAT_PERIOD * 10)); // set an upper sanity limit to avoid overflow - return (((age < (ZT_PATH_HEARTBEAT_PERIOD + 5000)) ? l : (l + 0xffff + age)) * (int)((ZT_INETADDRESS_MAX_SCOPE - _ipScope) + 1)); + const int l = (long)_latency; + const int age = (long)std::min((now - _lastIn),(int64_t)(ZT_PATH_HEARTBEAT_PERIOD * 10)); // set an upper sanity limit to avoid overflow + return (((age < (ZT_PATH_HEARTBEAT_PERIOD + 5000)) ? l : (l + 0xffff + age)) * (long)((ZT_INETADDRESS_MAX_SCOPE - _ipScope) + 1)); } + /** + * @return True if this path is alive (receiving heartbeats) + */ + inline bool alive(const int64_t now) const { return ((now - _lastIn) < (ZT_PATH_HEARTBEAT_PERIOD + 5000)); } + /** * @return True if this path needs a heartbeat */ -- cgit v1.2.3