summaryrefslogtreecommitdiff
path: root/node/Path.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-10-25 15:44:10 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-10-25 15:44:10 -0700
commit508fa6a7fed894fd616239c04aeb0c2e8f6b9022 (patch)
treedbc603eb4353bb70099d4915c171cf331f2ce94c /node/Path.hpp
parent71bdaa95087536954f1f1cb7b4652fd9b33be587 (diff)
downloadinfinitytier-508fa6a7fed894fd616239c04aeb0c2e8f6b9022.tar.gz
infinitytier-508fa6a7fed894fd616239c04aeb0c2e8f6b9022.zip
A few fixes for cluster mode.
Diffstat (limited to 'node/Path.hpp')
-rw-r--r--node/Path.hpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/node/Path.hpp b/node/Path.hpp
index 80132c13..ab52ced6 100644
--- a/node/Path.hpp
+++ b/node/Path.hpp
@@ -281,14 +281,19 @@ 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
*/
inline bool needsHeartbeat(const int64_t now) const { return ((now - _lastOut) >= ZT_PATH_HEARTBEAT_PERIOD); }