diff options
| -rw-r--r-- | src/main.c | 1 | ||||
| -rw-r--r-- | src/peers.c | 9 | ||||
| -rw-r--r-- | src/peers.h | 1 | ||||
| -rw-r--r-- | src/routing.c | 7 |
4 files changed, 16 insertions, 2 deletions
@@ -159,6 +159,7 @@ int main(int argc, char** argv) { metric_init(); routing_update_metrics(); + peer_update_metrics(); size_t outLen; const char *id = base64_encode((unsigned char*)myID.inner_b, 20, &outLen); diff --git a/src/peers.c b/src/peers.c index f278be2..d320e30 100644 --- a/src/peers.c +++ b/src/peers.c @@ -115,7 +115,6 @@ int add_peer(struct infohash* infohash, struct addr* peer, time_t now) { if(!entry->set) { entry->set = true; entry->key = *infohash; - entry->last_seen = now; peer_table_load++; peer_status.hashes++; prom_counter_inc(hashes, NULL); @@ -191,3 +190,11 @@ void expire_hashes(time_t now) { check_duplicates(); prom_gauge_set(current_hashes, (double)peer_table_load, NULL); } + +void peer_update_metrics() { + time_t now = time(NULL); + for(size_t i = 0; i < peer_table_size; i++) { + if(peer_table[i].set) continue; + if(now < peer_table[i].last_seen) dbg("%d was seen after now? (%ld < %ld)", i, now, peer_table[i].last_seen); + } +} diff --git a/src/peers.h b/src/peers.h index 8bd6b44..2c7845b 100644 --- a/src/peers.h +++ b/src/peers.h @@ -37,3 +37,4 @@ int add_peer(struct infohash* infohash, struct addr* peer, time_t now); void get_peers(struct infohash* infohash, struct addr **peers, size_t *peers_len); void expire_hashes(time_t now); +void peer_update_metrics(); diff --git a/src/routing.c b/src/routing.c index 7c10e16..30f0deb 100644 --- a/src/routing.c +++ b/src/routing.c @@ -73,7 +73,12 @@ void routing_update_metrics() { prom_gauge_set(routing_table_occupied, filled, (const char*[]){buf}); } - dbg("Update metrics!!"); + + time_t reasonable = time(NULL) + 120; + for(size_t i = 0; i < RT_SIZE; i++) { + if(pTable->table[i].set) continue; + if(reasonable < pTable->table[i].expire) dbg("%d will expire quite far into the future after now? (%ld < %ld)", i, reasonable, pTable->table[i].expire); + } } void routing_flush() { |
