Browse Source

Clean accesslists every five minutes

dynamic-accesslists
Dirk Engling 2 years ago
parent
commit
f62398c748
  1. 12
      ot_accesslist.c
  2. 1
      ot_accesslist.h
  3. 4
      ot_clean.c

12
ot_accesslist.c

@ -369,6 +369,18 @@ void accesslist_deinit( void ) { @@ -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 ) {

1
ot_accesslist.h

@ -15,6 +15,7 @@ @@ -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

4
ot_clean.c

@ -17,6 +17,7 @@ @@ -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 ) { @@ -123,6 +124,9 @@ static void * clean_worker( void * args ) {
usleep( OT_CLEAN_SLEEP );
}
stats_cleanup();
#ifdef WANT_ACCESSLIST
accesslist_cleanup();
#endif
}
return NULL;
}

Loading…
Cancel
Save