summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2022-11-24 16:38:26 +0100
committerDirk Engling <erdgeist@erdgeist.org>2022-11-24 16:38:26 +0100
commitf62398c7483e8ce9122e86cc2a09abda5f3745e3 (patch)
tree0339deeaa7e6050bf99c57cdb4b57368b23b401b
parentbe825f57597b0e9dcf07d257e93f03e30935f7db (diff)
Clean accesslists every five minutes
-rw-r--r--ot_accesslist.c12
-rw-r--r--ot_accesslist.h1
-rw-r--r--ot_clean.c4
3 files changed, 17 insertions, 0 deletions
diff --git a/ot_accesslist.c b/ot_accesslist.c
index 078cebd..2fc146c 100644
--- a/ot_accesslist.c
+++ b/ot_accesslist.c
@@ -369,6 +369,18 @@ void accesslist_deinit( void ) {
369 pthread_cancel( thread_id ); 369 pthread_cancel( thread_id );
370 pthread_mutex_destroy(&g_accesslist_mutex); 370 pthread_mutex_destroy(&g_accesslist_mutex);
371} 371}
372
373void accesslist_cleanup( void ) {
374 pthread_mutex_lock(&g_accesslist_mutex);
375
376 accesslist_clean(g_accesslist);
377#if WANT_DYNAMIC_ACCESSLIST
378 accesslist_clean(g_accesslist_add);
379 accesslist_clean(g_accesslist_delete);
380#endif
381
382 pthread_mutex_unlock(&g_accesslist_mutex);
383}
372#endif 384#endif
373 385
374int address_in_net( const ot_ip6 address, const ot_net *net ) { 386int address_in_net( const ot_ip6 address, const ot_net *net ) {
diff --git a/ot_accesslist.h b/ot_accesslist.h
index e86969b..9280fcb 100644
--- a/ot_accesslist.h
+++ b/ot_accesslist.h
@@ -15,6 +15,7 @@
15void accesslist_init( void ); 15void accesslist_init( void );
16void accesslist_deinit( void ); 16void accesslist_deinit( void );
17int accesslist_hashisvalid( ot_hash hash ); 17int accesslist_hashisvalid( ot_hash hash );
18void accesslist_cleanup( void );
18 19
19extern char *g_accesslist_filename; 20extern char *g_accesslist_filename;
20#ifdef WANT_DYNAMIC_ACCESSLIST 21#ifdef WANT_DYNAMIC_ACCESSLIST
diff --git a/ot_clean.c b/ot_clean.c
index 4c03416..139bedb 100644
--- a/ot_clean.c
+++ b/ot_clean.c
@@ -17,6 +17,7 @@
17#include "ot_vector.h" 17#include "ot_vector.h"
18#include "ot_clean.h" 18#include "ot_clean.h"
19#include "ot_stats.h" 19#include "ot_stats.h"
20#include "ot_accesslist.h"
20 21
21/* Returns amount of removed peers */ 22/* Returns amount of removed peers */
22static ssize_t clean_single_bucket( ot_peer *peers, size_t peer_count, time_t timedout, int *removed_seeders ) { 23static 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 usleep( OT_CLEAN_SLEEP ); 124 usleep( OT_CLEAN_SLEEP );
124 } 125 }
125 stats_cleanup(); 126 stats_cleanup();
127#ifdef WANT_ACCESSLIST
128 accesslist_cleanup();
129#endif
126 } 130 }
127 return NULL; 131 return NULL;
128} 132}