summaryrefslogtreecommitdiff
path: root/osdep
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2017-10-02 15:52:57 -0700
committerGrant Limberg <grant.limberg@zerotier.com>2017-10-02 15:52:57 -0700
commitb1d60df44cb24589bc5718da932ef4bb54168fa3 (patch)
treec240b5b626f534f4a3673bedbdf6d80b59a8d475 /osdep
parent7cf70d111ac3bfc1bf6aa7e3ec8d9c83e35f48a1 (diff)
downloadinfinitytier-b1d60df44cb24589bc5718da932ef4bb54168fa3.tar.gz
infinitytier-b1d60df44cb24589bc5718da932ef4bb54168fa3.zip
timestamps changed from uint64_t to int64_t
There were cases in the code where time calculations and comparisons were overflowing and causing connection instability. This will keep time calculations within expected ranges.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/OSUtils.hpp6
-rw-r--r--osdep/PortMapper.cpp2
2 files changed, 4 insertions, 4 deletions
diff --git a/osdep/OSUtils.hpp b/osdep/OSUtils.hpp
index 8683ba25..8f66f850 100644
--- a/osdep/OSUtils.hpp
+++ b/osdep/OSUtils.hpp
@@ -200,7 +200,7 @@ public:
/**
* @return Current time in milliseconds since epoch
*/
- static inline uint64_t now()
+ static inline int64_t now()
{
#ifdef __WINDOWS__
FILETIME ft;
@@ -210,7 +210,7 @@ public:
SystemTimeToFileTime(&st,&ft);
tmp.LowPart = ft.dwLowDateTime;
tmp.HighPart = ft.dwHighDateTime;
- return ( ((tmp.QuadPart - 116444736000000000ULL) / 10000L) + st.wMilliseconds );
+ return (int64_t)( ((tmp.QuadPart - 116444736000000000LL) / 10000L) + st.wMilliseconds );
#else
struct timeval tv;
#ifdef __LINUX__
@@ -218,7 +218,7 @@ public:
#else
gettimeofday(&tv,(struct timezone *)0);
#endif
- return ( (1000ULL * (uint64_t)tv.tv_sec) + (uint64_t)(tv.tv_usec / 1000) );
+ return ( (1000LL * (int64_t)tv.tv_sec) + (int64_t)(tv.tv_usec / 1000) );
#endif
};
diff --git a/osdep/PortMapper.cpp b/osdep/PortMapper.cpp
index 0da00653..825972b0 100644
--- a/osdep/PortMapper.cpp
+++ b/osdep/PortMapper.cpp
@@ -131,7 +131,7 @@ public:
InetAddress publicAddress;
sendpublicaddressrequest(&natpmp);
- uint64_t myTimeout = OSUtils::now() + 5000;
+ int64_t myTimeout = OSUtils::now() + 5000;
do {
fd_set fds;
struct timeval timeout;