summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
authorerdgeist <>2007-01-29 02:02:03 +0000
committererdgeist <>2007-01-29 02:02:03 +0000
commit5a3d6b402979d7d9bf8da470f081bb6ca4122cf6 (patch)
tree21033b84fbd2e7cb98bdd1a5259f0b6e6c56275a /trackerlogic.c
parent4c6bcc89cef49841e5eba095435c49cbdfbf2801 (diff)
We now answer as soon as the first \n is seen
We do not copy input buffer to socket's input array anymore, if we find \n in first buffer We simplified parsing of input string We removed asserts that were needed to debug negative seeder counts We split static input and output buffers for obvious reasons We enlarged static output buffer to prepare multi scrape functionality We removed -lm from Makefile, this lib was only needed, when our random algorithm worked on floats We close fds now that come with an empty iocookie into write loop, those don't make sense We documented query string parser in opentracker.c a lot better to help auditing
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index b1d7349..f4c61d3 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -14,7 +14,6 @@
14#include <math.h> 14#include <math.h>
15#include <glob.h> 15#include <glob.h>
16 16
17#include <assert.h>
18#include <errno.h> 17#include <errno.h>
19#include "scan.h" 18#include "scan.h"
20#include "byte.h" 19#include "byte.h"
@@ -207,16 +206,11 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) {
207 if( OT_FLAG(peer) & PEER_FLAG_SEEDING ) 206 if( OT_FLAG(peer) & PEER_FLAG_SEEDING )
208 torrent->peer_list->seed_count[0]++; 207 torrent->peer_list->seed_count[0]++;
209 208
210 assert( torrent->peer_list->seed_count[0] <= torrent->peer_list->peers[0].size );
211
212 for( i=1; i<OT_POOLS_COUNT; ++i ) { 209 for( i=1; i<OT_POOLS_COUNT; ++i ) {
213 switch( vector_remove_peer( &torrent->peer_list->peers[i], peer ) ) { 210 switch( vector_remove_peer( &torrent->peer_list->peers[i], peer ) ) {
214 case 0: continue; 211 case 0: continue;
215 case 2: torrent->peer_list->seed_count[i]--; 212 case 2: torrent->peer_list->seed_count[i]--;
216 case 1: default: 213 case 1: default: return torrent;
217 assert( torrent->peer_list->seed_count[i] >= 0 );
218 assert( torrent->peer_list->seed_count[i] <= torrent->peer_list->peers[i].size );
219 return torrent;
220 } 214 }
221 } 215 }
222 } else { 216 } else {
@@ -225,9 +219,6 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) {
225 if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) ) 219 if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) )
226 torrent->peer_list->seed_count[0]++; 220 torrent->peer_list->seed_count[0]++;
227 memmove( peer_dest, peer, sizeof( ot_peer ) ); 221 memmove( peer_dest, peer, sizeof( ot_peer ) );
228
229 assert( torrent->peer_list->seed_count[0] >= 0 );
230 assert( torrent->peer_list->seed_count[0] <= torrent->peer_list->peers[0].size );
231 } 222 }
232 223
233 return torrent; 224 return torrent;
@@ -463,10 +454,7 @@ void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ) {
463 switch( vector_remove_peer( &torrent->peer_list->peers[i], peer ) ) { 454 switch( vector_remove_peer( &torrent->peer_list->peers[i], peer ) ) {
464 case 0: continue; 455 case 0: continue;
465 case 2: torrent->peer_list->seed_count[i]--; 456 case 2: torrent->peer_list->seed_count[i]--;
466 case 1: default: 457 case 1: default: return;
467 assert( torrent->peer_list->seed_count[i] >= 0 );
468 assert( torrent->peer_list->seed_count[i] <= torrent->peer_list->peers[i].size );
469 return;
470 } 458 }
471} 459}
472 460
@@ -476,10 +464,10 @@ int init_logic( const char * const serverdir ) {
476 return -1; 464 return -1;
477 } 465 }
478 466
479 srandom( time(NULL)); 467 srandom( time(NULL) );
480 468
481 /* Initialize control structures */ 469 /* Initialize control structures */
482 byte_zero( all_torrents, sizeof (all_torrents)); 470 byte_zero( all_torrents, sizeof (all_torrents) );
483 471
484 return 0; 472 return 0;
485} 473}