diff options
-rw-r--r-- | trackerlogic.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index d112abd..2c0dd4f 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
@@ -224,14 +224,15 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) { | |||
224 | peer_pool = &torrent->peer_list->peers[0]; | 224 | peer_pool = &torrent->peer_list->peers[0]; |
225 | peer_dest = vector_find_or_insert( peer_pool, (void*)peer, sizeof( ot_peer ), OT_PEER_COMPARE_SIZE, &exactmatch ); | 225 | peer_dest = vector_find_or_insert( peer_pool, (void*)peer, sizeof( ot_peer ), OT_PEER_COMPARE_SIZE, &exactmatch ); |
226 | 226 | ||
227 | if( OT_FLAG( peer ) & PEER_FLAG_COMPLETED ) | ||
228 | torrent->peer_list->downloaded++; | ||
229 | |||
230 | /* If we hadn't had a match in current pool, create peer there and | 227 | /* If we hadn't had a match in current pool, create peer there and |
231 | remove it from all older pools */ | 228 | remove it from all older pools */ |
232 | if( !exactmatch ) { | 229 | if( !exactmatch ) { |
233 | int i; | 230 | int i; |
234 | memmove( peer_dest, peer, sizeof( ot_peer ) ); | 231 | memmove( peer_dest, peer, sizeof( ot_peer ) ); |
232 | |||
233 | if( OT_FLAG( peer ) & PEER_FLAG_COMPLETED ) | ||
234 | torrent->peer_list->downloaded++; | ||
235 | |||
235 | if( OT_FLAG(peer) & PEER_FLAG_SEEDING ) | 236 | if( OT_FLAG(peer) & PEER_FLAG_SEEDING ) |
236 | torrent->peer_list->seed_count[0]++; | 237 | torrent->peer_list->seed_count[0]++; |
237 | 238 | ||
@@ -247,6 +248,11 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) { | |||
247 | torrent->peer_list->seed_count[0]--; | 248 | torrent->peer_list->seed_count[0]--; |
248 | if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) ) | 249 | if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) ) |
249 | torrent->peer_list->seed_count[0]++; | 250 | torrent->peer_list->seed_count[0]++; |
251 | if( !(OT_FLAG( peer_dest ) & PEER_FLAG_COMPLETED ) && (OT_FLAG( peer ) & PEER_FLAG_COMPLETED ) ) | ||
252 | torrent->peer_list->downloaded++; | ||
253 | if( OT_FLAG( peer_dest ) & PEER_FLAG_COMPLETED ) | ||
254 | OT_FLAG( peer ) |= PEER_FLAG_COMPLETED; | ||
255 | |||
250 | memmove( peer_dest, peer, sizeof( ot_peer ) ); | 256 | memmove( peer_dest, peer, sizeof( ot_peer ) ); |
251 | } | 257 | } |
252 | 258 | ||