Skip to content
Permalink
Browse files

TraversalServer: use C++ <chrono> instead of gettimeofday

  • Loading branch information...
ligfx authored and leoetlino committed Nov 1, 2017
1 parent e7bc868 commit 916a97b8693f223ca3ef85af961fc4c714485e28
Showing with 4 additions and 7 deletions.
  1. +4 −7 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)

0 comments on commit 916a97b

Please sign in to comment.
You can’t perform that action at this time.