diff options
| author | Léo Lam <leo@leolam.fr> | 2019-05-11 10:44:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-11 10:44:49 +0200 |
| commit | e35ccd5a9aada7c5f1a9563ac20f1650977bcedd (patch) | |
| tree | 8ba04245b0a92bda3caa5d5165a7e51cf5d056c1 /Source/Core/Common/TraversalServer.cpp | |
| parent | 3ab06dcd02ea6040c2620a8ce8be144c65534c2d (diff) | |
| parent | 916a97b8693f223ca3ef85af961fc4c714485e28 (diff) | |
Merge pull request #8091 from leoetlino/traversal-chrono
TraversalServer: use C++ <chrono> instead of gettimeofday
Diffstat (limited to 'Source/Core/Common/TraversalServer.cpp')
| -rw-r--r-- | Source/Core/Common/TraversalServer.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Source/Core/Common/TraversalServer.cpp b/Source/Core/Common/TraversalServer.cpp index 1ff228c515..80d32d52fa 100644 --- a/Source/Core/Common/TraversalServer.cpp +++ b/Source/Core/Common/TraversalServer.cpp @@ -3,13 +3,13 @@ // The central server implementation. #include <arpa/inet.h> #include <cerrno> +#include <chrono> #include <cstdio> #include <cstdlib> #include <cstring> #include <fcntl.h> #include <netinet/in.h> #include <sys/socket.h> -#include <sys/time.h> #include <sys/types.h> #include <unistd.h> #include <unordered_map> @@ -411,12 +411,9 @@ int main() // note: switch to recvmmsg (yes, mmsg) if this becomes // expensive rv = recvfrom(sock, &packet, sizeof(packet), 0, (sockaddr*)&raddr, &addrLen); - if (gettimeofday(&tv, nullptr) < 0) - { - perror("gettimeofday"); - exit(1); - } - currentTime = (u64)tv.tv_sec * 1000000 + tv.tv_usec; + currentTime = std::chrono::duration_cast<std::chrono::microseconds>( + std::chrono::system_clock::now().time_since_epoch()) + .count(); if (rv < 0) { if (errno != EINTR && errno != EAGAIN) |
