From 9d53bc5d1dabd3142f58cafd9fffa18f783f96df Mon Sep 17 00:00:00 2001 From: irungentoo Date: Sat, 24 May 2014 22:20:24 -0400 Subject: [PATCH] This function only needs to be ran once per second when epoll is enabled because all it does then is send pings and check timeouts which are calculated by the second. --- toxcore/TCP_server.c | 7 +++++++ toxcore/TCP_server.h | 1 + 2 files changed, 8 insertions(+) diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index fdab4870d..2dcd6f50d 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c @@ -1031,6 +1031,13 @@ static void do_TCP_unconfirmed(TCP_Server *TCP_server) static void do_TCP_confirmed(TCP_Server *TCP_server) { +#ifdef TCP_SERVER_USE_EPOLL + + if (TCP_server->last_run_pinged == unix_time()) + return; + + TCP_server->last_run_pinged = unix_time(); +#endif uint32_t i; for (i = 0; i < TCP_server->size_accepted_connections; ++i) { diff --git a/toxcore/TCP_server.h b/toxcore/TCP_server.h index e28567261..1573d212a 100644 --- a/toxcore/TCP_server.h +++ b/toxcore/TCP_server.h @@ -110,6 +110,7 @@ typedef struct { #ifdef TCP_SERVER_USE_EPOLL int efd; + uint64_t last_run_pinged; #endif sock_t *socks_listening; unsigned int num_listening_socks;