mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-16 09:19:23 +01:00
Merge pull request #8091 from leoetlino/traversal-chrono
TraversalServer: use C++ <chrono> instead of gettimeofday
This commit is contained in:
commit
e35ccd5a9a
@ -3,13 +3,13 @@
|
|||||||
// The central server implementation.
|
// The central server implementation.
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
#include <chrono>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -411,12 +411,9 @@ int main()
|
|||||||
// note: switch to recvmmsg (yes, mmsg) if this becomes
|
// note: switch to recvmmsg (yes, mmsg) if this becomes
|
||||||
// expensive
|
// expensive
|
||||||
rv = recvfrom(sock, &packet, sizeof(packet), 0, (sockaddr*)&raddr, &addrLen);
|
rv = recvfrom(sock, &packet, sizeof(packet), 0, (sockaddr*)&raddr, &addrLen);
|
||||||
if (gettimeofday(&tv, nullptr) < 0)
|
currentTime = std::chrono::duration_cast<std::chrono::microseconds>(
|
||||||
{
|
std::chrono::system_clock::now().time_since_epoch())
|
||||||
perror("gettimeofday");
|
.count();
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
currentTime = (u64)tv.tv_sec * 1000000 + tv.tv_usec;
|
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
{
|
{
|
||||||
if (errno != EINTR && errno != EAGAIN)
|
if (errno != EINTR && errno != EAGAIN)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user