summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
authorerdgeist <>2007-01-27 16:06:13 +0000
committererdgeist <>2007-01-27 16:06:13 +0000
commitc094695add94493ab46d535b6fca1801efa127c2 (patch)
tree6dd0f7ee88c5a4a2951a44f9f7f2bd873880b22f /trackerlogic.c
parent65675cd4daf5c5d26b13e32d1a8779aa8b689f88 (diff)
account downloaded before early returns
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index 83a4eba..6b8dba5 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -195,6 +195,9 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) {
195 peer_pool = &torrent->peer_list->peers[0]; 195 peer_pool = &torrent->peer_list->peers[0];
196 peer_dest = vector_find_or_insert( peer_pool, (void*)peer, sizeof( ot_peer ), OT_PEER_COMPARE_SIZE, &exactmatch ); 196 peer_dest = vector_find_or_insert( peer_pool, (void*)peer, sizeof( ot_peer ), OT_PEER_COMPARE_SIZE, &exactmatch );
197 197
198 if( OT_FLAG(peer) & PEER_FLAG_COMPLETED )
199 torrent->peer_list->downloaded++;
200
198 /* If we hadn't had a match in current pool, create peer there and 201 /* If we hadn't had a match in current pool, create peer there and
199 remove it from all older pools */ 202 remove it from all older pools */
200 if( !exactmatch ) { 203 if( !exactmatch ) {
@@ -215,8 +218,6 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) {
215 if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) ) 218 if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) )
216 torrent->peer_list->seed_count[0]++; 219 torrent->peer_list->seed_count[0]++;
217 } 220 }
218 if( OT_FLAG(peer) & PEER_FLAG_COMPLETED )
219 torrent->peer_list->downloaded++;
220 221
221 return torrent; 222 return torrent;
222} 223}
@@ -435,13 +436,13 @@ void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ) {
435 int exactmatch, i; 436 int exactmatch, i;
436 ot_vector *torrents_list = &all_torrents[*hash[0]]; 437 ot_vector *torrents_list = &all_torrents[*hash[0]];
437 ot_torrent *torrent = binary_search( hash, torrents_list->data, torrents_list->size, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch ); 438 ot_torrent *torrent = binary_search( hash, torrents_list->data, torrents_list->size, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch );
438 439
439 if( !exactmatch ) return; 440 if( !exactmatch ) return;
440 441
441 /* Maybe this does the job */ 442 /* Maybe this does the job */
442 if( clean_peerlist( NOW, torrent->peer_list ) ) { 443 if( clean_peerlist( NOW, torrent->peer_list ) ) {
443#ifdef WANT_CLOSED_TRACKER 444#ifdef WANT_CLOSED_TRACKER
444 if( !g_closedtracker ) 445 if( !g_closedtracker )
445#endif 446#endif
446 vector_remove_torrent( torrents_list, hash ); 447 vector_remove_torrent( torrents_list, hash );
447 return; 448 return;