Browse Source
Merge pull request #109 from realjiangms/fix_purge_expired_registrations_kickoff_2.4-stable
Fix purge expired registrations kickoff 2.4 stable
2.4-stable
Emanuele Faranda
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
10 additions and
8 deletions
-
edge_utils.c
-
n2n.c
-
n2n.h
-
sn.c
|
|
@ -1419,6 +1419,8 @@ int run_edge_loop(n2n_edge_t * eee, int *keep_running) { |
|
|
|
size_t numPurged; |
|
|
|
time_t lastIfaceCheck=0; |
|
|
|
time_t lastTransop=0; |
|
|
|
time_t last_purge_known = 0; |
|
|
|
time_t last_purge_pending = 0; |
|
|
|
#ifdef __ANDROID_NDK__ |
|
|
|
time_t lastArpPeriod=0; |
|
|
|
#endif |
|
|
@ -1502,8 +1504,8 @@ int run_edge_loop(n2n_edge_t * eee, int *keep_running) { |
|
|
|
|
|
|
|
update_supernode_reg(eee, nowTime); |
|
|
|
|
|
|
|
numPurged = purge_expired_registrations(&(eee->known_peers)); |
|
|
|
numPurged += purge_expired_registrations(&(eee->pending_peers)); |
|
|
|
numPurged = purge_expired_registrations(&(eee->known_peers), &last_purge_known); |
|
|
|
numPurged += purge_expired_registrations(&(eee->pending_peers), &last_purge_pending); |
|
|
|
|
|
|
|
if(numPurged > 0) { |
|
|
|
traceEvent(TRACE_NORMAL, "Peer removed: pending=%u, operational=%u", |
|
|
|
|
|
@ -307,18 +307,17 @@ void peer_list_add(struct peer_info * * list, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
size_t purge_expired_registrations(struct peer_info ** peer_list) { |
|
|
|
static time_t last_purge = 0; |
|
|
|
size_t purge_expired_registrations(struct peer_info ** peer_list, time_t* p_last_purge) { |
|
|
|
time_t now = time(NULL); |
|
|
|
size_t num_reg = 0; |
|
|
|
|
|
|
|
if((now - last_purge) < PURGE_REGISTRATION_FREQUENCY) return 0; |
|
|
|
if((now - (*p_last_purge)) < PURGE_REGISTRATION_FREQUENCY) return 0; |
|
|
|
|
|
|
|
traceEvent(TRACE_INFO, "Purging old registrations"); |
|
|
|
|
|
|
|
num_reg = purge_peer_list(peer_list, now-REGISTRATION_TIMEOUT); |
|
|
|
|
|
|
|
last_purge = now; |
|
|
|
(*p_last_purge) = now; |
|
|
|
traceEvent(TRACE_INFO, "Remove %ld registrations", num_reg); |
|
|
|
|
|
|
|
return num_reg; |
|
|
|
|
|
@ -297,7 +297,7 @@ size_t peer_list_size( const struct peer_info * list ); |
|
|
|
size_t purge_peer_list( struct peer_info ** peer_list, |
|
|
|
time_t purge_before ); |
|
|
|
size_t clear_peer_list( struct peer_info ** peer_list ); |
|
|
|
size_t purge_expired_registrations( struct peer_info ** peer_list ); |
|
|
|
size_t purge_expired_registrations( struct peer_info ** peer_list, time_t* p_last_purge ); |
|
|
|
|
|
|
|
/* version.c */ |
|
|
|
extern char *n2n_sw_version, *n2n_sw_osName, *n2n_sw_buildDate; |
|
|
|
|
|
@ -859,6 +859,7 @@ static int run_loop( n2n_sn_t * sss ) |
|
|
|
{ |
|
|
|
uint8_t pktbuf[N2N_SN_PKTBUF_SIZE]; |
|
|
|
int keep_running=1; |
|
|
|
time_t last_purge_edges = 0; |
|
|
|
|
|
|
|
sss->start_time = time(NULL); |
|
|
|
|
|
|
@ -934,7 +935,7 @@ static int run_loop( n2n_sn_t * sss ) |
|
|
|
traceEvent( TRACE_DEBUG, "timeout" ); |
|
|
|
} |
|
|
|
|
|
|
|
purge_expired_registrations( &(sss->edges) ); |
|
|
|
purge_expired_registrations( &(sss->edges), &last_purge_edges ); |
|
|
|
|
|
|
|
} /* while */ |
|
|
|
|
|
|
|