diff options
-rw-r--r-- | ot_clean.c | 2 | ||||
-rw-r--r-- | ot_vector.c | 4 | ||||
-rw-r--r-- | ot_vector.h | 1 | ||||
-rw-r--r-- | trackerlogic.c | 12 |
4 files changed, 9 insertions, 10 deletions
@@ -45,7 +45,7 @@ static ssize_t clean_single_bucket( ot_peer *peers, size_t peer_count, size_t pe | |||
45 | (*removed_seeders)++; | 45 | (*removed_seeders)++; |
46 | } | 46 | } |
47 | 47 | ||
48 | return peers - insert_point; | 48 | return (peers - insert_point) / peer_size; |
49 | } | 49 | } |
50 | 50 | ||
51 | int clean_single_peer_list( ot_peerlist *peer_list, size_t peer_size ) { | 51 | int clean_single_peer_list( ot_peerlist *peer_list, size_t peer_size ) { |
diff --git a/ot_vector.c b/ot_vector.c index 36b326a..479e832 100644 --- a/ot_vector.c +++ b/ot_vector.c | |||
@@ -157,8 +157,8 @@ void vector_remove_torrent( ot_vector *vector, ot_torrent *match ) { | |||
157 | 157 | ||
158 | /* If this is being called after a unsuccessful malloc() for peer_list | 158 | /* If this is being called after a unsuccessful malloc() for peer_list |
159 | in add_peer_to_torrent, match->peer_list actually might be NULL */ | 159 | in add_peer_to_torrent, match->peer_list actually might be NULL */ |
160 | if( match->peer_list6) free_peerlist( match->peer_list6 ); | 160 | free_peerlist( match->peer_list6 ); |
161 | if( match->peer_list4) free_peerlist( match->peer_list4 ); | 161 | free_peerlist( match->peer_list4 ); |
162 | 162 | ||
163 | memmove( match, match + 1, sizeof(ot_torrent) * ( end - match - 1 ) ); | 163 | memmove( match, match + 1, sizeof(ot_torrent) * ( end - match - 1 ) ); |
164 | if( ( --vector->size * OT_VECTOR_SHRINK_THRESH < vector->space ) && ( vector->space >= OT_VECTOR_SHRINK_RATIO * OT_VECTOR_MIN_MEMBERS ) ) { | 164 | if( ( --vector->size * OT_VECTOR_SHRINK_THRESH < vector->space ) && ( vector->space >= OT_VECTOR_SHRINK_RATIO * OT_VECTOR_MIN_MEMBERS ) ) { |
diff --git a/ot_vector.h b/ot_vector.h index f60c291..37e2592 100644 --- a/ot_vector.h +++ b/ot_vector.h | |||
@@ -32,5 +32,6 @@ void vector_remove_torrent( ot_vector *vector, ot_torrent *match ); | |||
32 | /* For ot_clean.c */ | 32 | /* For ot_clean.c */ |
33 | void vector_redistribute_buckets( ot_peerlist * peer_list, size_t peer_size ); | 33 | void vector_redistribute_buckets( ot_peerlist * peer_list, size_t peer_size ); |
34 | void vector_fixup_peers( ot_vector * vector, size_t peer_size ); | 34 | void vector_fixup_peers( ot_vector * vector, size_t peer_size ); |
35 | void vector_clean_list( ot_vector * vector, int num_buckets); | ||
35 | 36 | ||
36 | #endif | 37 | #endif |
diff --git a/trackerlogic.c b/trackerlogic.c index 5e32f13..11113d2 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | /* Opentracker */ | 22 | /* Opentracker */ |
23 | #include "trackerlogic.h" | 23 | #include "trackerlogic.h" |
24 | #include "ot_vector.h" | ||
24 | #include "ot_mutex.h" | 25 | #include "ot_mutex.h" |
25 | #include "ot_stats.h" | 26 | #include "ot_stats.h" |
26 | #include "ot_clean.h" | 27 | #include "ot_clean.h" |
@@ -34,13 +35,10 @@ size_t return_peers_for_torrent( struct ot_workstruct * ws, ot_torrent *torrent, | |||
34 | 35 | ||
35 | void free_peerlist( ot_peerlist *peer_list ) { | 36 | void free_peerlist( ot_peerlist *peer_list ) { |
36 | if( peer_list->peers.data ) { | 37 | if( peer_list->peers.data ) { |
37 | if( OT_PEERLIST_HASBUCKETS( peer_list ) ) { | 38 | if( OT_PEERLIST_HASBUCKETS( peer_list ) ) |
38 | ot_vector *bucket_list = (ot_vector*)(peer_list->peers.data); | 39 | vector_clean_list( (ot_vector*)peer_list->peers.data, peer_list->peers.size ); |
39 | 40 | else | |
40 | while( peer_list->peers.size-- ) | 41 | free( peer_list->peers.data ); |
41 | free( bucket_list++->data ); | ||
42 | } | ||
43 | free( peer_list->peers.data ); | ||
44 | } | 42 | } |
45 | free( peer_list ); | 43 | free( peer_list ); |
46 | } | 44 | } |