diff options
Diffstat (limited to 'trackerlogic.c')
| -rw-r--r-- | trackerlogic.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index 0207fad..7b5b94a 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
| @@ -193,11 +193,14 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) { | |||
| 193 | // | 193 | // |
| 194 | size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply ) { | 194 | size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply ) { |
| 195 | char *r = reply; | 195 | char *r = reply; |
| 196 | unsigned long peer_count, index; | 196 | unsigned long peer_count, seed_count, index; |
| 197 | signed long pool_offset = -1, pool_index = 0; | 197 | signed long pool_offset = -1, pool_index = 0; |
| 198 | signed long wert = -1; | 198 | signed long wert = -1; |
| 199 | 199 | ||
| 200 | for( peer_count=index=0; index<OT_POOLS_COUNT; ++index) peer_count += torrent->peer_list->peers[index].size; | 200 | for( peer_count=seed_count=index=0; index<OT_POOLS_COUNT; ++index) { |
| 201 | peer_count += torrent->peer_list->peers[index].size; | ||
| 202 | seed_count += torrent->peer_list->seed_count[index]; | ||
| 203 | } | ||
| 201 | if( peer_count < amount ) amount = peer_count; | 204 | if( peer_count < amount ) amount = peer_count; |
| 202 | 205 | ||
| 203 | r += FORMAT_FORMAT_STRING( r, "d5:peers%li:",6*amount ); | 206 | r += FORMAT_FORMAT_STRING( r, "d5:peers%li:",6*amount ); |
| @@ -215,7 +218,8 @@ size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char | |||
| 215 | MEMMOVE( r, ((ot_peer*)torrent->peer_list->peers[pool_index].data) + pool_offset, 6 ); | 218 | MEMMOVE( r, ((ot_peer*)torrent->peer_list->peers[pool_index].data) + pool_offset, 6 ); |
| 216 | r += 6; | 219 | r += 6; |
| 217 | } | 220 | } |
| 218 | *r++ = 'e'; | 221 | r += FORMAT_FORMAT_STRING( r, "8:completei%lie10:incompletei%lie8:intervali60ee", seed_count, peer_count-seed_count ); |
| 222 | |||
| 219 | return r - reply; | 223 | return r - reply; |
| 220 | } | 224 | } |
| 221 | 225 | ||
