1
0
mirror of git://erdgeist.org/opentracker synced 2025-03-12 05:31:02 +00:00

Clean accesslists every five minutes

This commit is contained in:
Dirk Engling 2022-11-24 16:38:26 +01:00
parent be825f5759
commit f62398c748
3 changed files with 17 additions and 0 deletions

View File

@ -369,6 +369,18 @@ void accesslist_deinit( void ) {
pthread_cancel( thread_id );
pthread_mutex_destroy(&g_accesslist_mutex);
}
void accesslist_cleanup( void ) {
pthread_mutex_lock(&g_accesslist_mutex);
accesslist_clean(g_accesslist);
#if WANT_DYNAMIC_ACCESSLIST
accesslist_clean(g_accesslist_add);
accesslist_clean(g_accesslist_delete);
#endif
pthread_mutex_unlock(&g_accesslist_mutex);
}
#endif
int address_in_net( const ot_ip6 address, const ot_net *net ) {

View File

@ -15,6 +15,7 @@
void accesslist_init( void );
void accesslist_deinit( void );
int accesslist_hashisvalid( ot_hash hash );
void accesslist_cleanup( void );
extern char *g_accesslist_filename;
#ifdef WANT_DYNAMIC_ACCESSLIST

View File

@ -17,6 +17,7 @@
#include "ot_vector.h"
#include "ot_clean.h"
#include "ot_stats.h"
#include "ot_accesslist.h"
/* Returns amount of removed peers */
static ssize_t clean_single_bucket( ot_peer *peers, size_t peer_count, time_t timedout, int *removed_seeders ) {
@ -123,6 +124,9 @@ static void * clean_worker( void * args ) {
usleep( OT_CLEAN_SLEEP );
}
stats_cleanup();
#ifdef WANT_ACCESSLIST
accesslist_cleanup();
#endif
}
return NULL;
}