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:
irungentoo 2013-11-30 21:52:50 -05:00
parent 2a75abb494
commit fcc1463fe1
2 changed files with 6 additions and 1 deletions

View File

@ -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)
{

View File

@ -149,6 +149,8 @@ typedef struct {
PING *ping;
Assoc *assoc;
uint64_t last_run;
} DHT;
/*----------------------------------------------------------------------------------*/