mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
The stuff in do_DHT only need to be run once per second.
Should lower CPU usage by a bit.
This commit is contained in:
parent
2a75abb494
commit
fcc1463fe1
|
@ -1662,11 +1662,14 @@ DHT *new_DHT(Net_Crypto *c)
|
||||||
void do_DHT(DHT *dht)
|
void do_DHT(DHT *dht)
|
||||||
{
|
{
|
||||||
unix_time_update();
|
unix_time_update();
|
||||||
|
if (dht->last_run == unix_time()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
do_Close(dht);
|
do_Close(dht);
|
||||||
do_DHT_friends(dht);
|
do_DHT_friends(dht);
|
||||||
do_NAT(dht);
|
do_NAT(dht);
|
||||||
do_toping(dht->ping);
|
do_toping(dht->ping);
|
||||||
|
dht->last_run = unix_time();
|
||||||
}
|
}
|
||||||
void kill_DHT(DHT *dht)
|
void kill_DHT(DHT *dht)
|
||||||
{
|
{
|
||||||
|
|
|
@ -149,6 +149,8 @@ typedef struct {
|
||||||
PING *ping;
|
PING *ping;
|
||||||
|
|
||||||
Assoc *assoc;
|
Assoc *assoc;
|
||||||
|
|
||||||
|
uint64_t last_run;
|
||||||
} DHT;
|
} DHT;
|
||||||
/*----------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user