From fcc1463fe1818ec8d12e2ccdf7769859f31792df Mon Sep 17 00:00:00 2001 From: irungentoo Date: Sat, 30 Nov 2013 21:52:50 -0500 Subject: [PATCH] The stuff in do_DHT only need to be run once per second. Should lower CPU usage by a bit. --- toxcore/DHT.c | 5 ++++- toxcore/DHT.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/toxcore/DHT.c b/toxcore/DHT.c index f49858bc2..236b8c164 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c @@ -1662,11 +1662,14 @@ DHT *new_DHT(Net_Crypto *c) void do_DHT(DHT *dht) { unix_time_update(); - + if (dht->last_run == unix_time()) { + return; + } do_Close(dht); do_DHT_friends(dht); do_NAT(dht); do_toping(dht->ping); + dht->last_run = unix_time(); } void kill_DHT(DHT *dht) { diff --git a/toxcore/DHT.h b/toxcore/DHT.h index 2f6334ee4..37328e5d7 100644 --- a/toxcore/DHT.h +++ b/toxcore/DHT.h @@ -149,6 +149,8 @@ typedef struct { PING *ping; Assoc *assoc; + + uint64_t last_run; } DHT; /*----------------------------------------------------------------------------------*/