Number of reported removed peers was too high, correct it by size of peer

master
Dirk Engling 9 months ago
parent db28465e0c
commit b7b84bdec4

@ -45,7 +45,7 @@ static ssize_t clean_single_bucket( ot_peer *peers, size_t peer_count, size_t pe
(*removed_seeders)++;
}
return peers - insert_point;
return (peers - insert_point) / peer_size;
}
int clean_single_peer_list( ot_peerlist *peer_list, size_t peer_size ) {

@ -157,8 +157,8 @@ void vector_remove_torrent( ot_vector *vector, ot_torrent *match ) {
/* If this is being called after a unsuccessful malloc() for peer_list
in add_peer_to_torrent, match->peer_list actually might be NULL */
if( match->peer_list6) free_peerlist( match->peer_list6 );
if( match->peer_list4) free_peerlist( match->peer_list4 );
free_peerlist( match->peer_list6 );
free_peerlist( match->peer_list4 );
memmove( match, match + 1, sizeof(ot_torrent) * ( end - match - 1 ) );
if( ( --vector->size * OT_VECTOR_SHRINK_THRESH < vector->space ) && ( vector->space >= OT_VECTOR_SHRINK_RATIO * OT_VECTOR_MIN_MEMBERS ) ) {

@ -32,5 +32,6 @@ void vector_remove_torrent( ot_vector *vector, ot_torrent *match );
/* For ot_clean.c */
void vector_redistribute_buckets( ot_peerlist * peer_list, size_t peer_size );
void vector_fixup_peers( ot_vector * vector, size_t peer_size );
void vector_clean_list( ot_vector * vector, int num_buckets);
#endif

@ -21,6 +21,7 @@
/* Opentracker */
#include "trackerlogic.h"
#include "ot_vector.h"
#include "ot_mutex.h"
#include "ot_stats.h"
#include "ot_clean.h"
@ -34,13 +35,10 @@ size_t return_peers_for_torrent( struct ot_workstruct * ws, ot_torrent *torrent,
void free_peerlist( ot_peerlist *peer_list ) {
if( peer_list->peers.data ) {
if( OT_PEERLIST_HASBUCKETS( peer_list ) ) {
ot_vector *bucket_list = (ot_vector*)(peer_list->peers.data);
while( peer_list->peers.size-- )
free( bucket_list++->data );
}
free( peer_list->peers.data );
if( OT_PEERLIST_HASBUCKETS( peer_list ) )
vector_clean_list( (ot_vector*)peer_list->peers.data, peer_list->peers.size );
else
free( peer_list->peers.data );
}
free( peer_list );
}

Loading…
Cancel
Save