mirror of
git://erdgeist.org/opentracker
synced 2025-01-13 16:30:06 +00:00
Trackerlogic done... not tested yet
This commit is contained in:
parent
31c20c515d
commit
d7c26dc71b
4
Makefile
4
Makefile
@ -1,6 +1,6 @@
|
||||
CC?=gcc
|
||||
CFLAGS+=-I../libowfat -Wall -pipe -g -ggdb
|
||||
LDFLAGS+=-L../libowfat/ -lowfat
|
||||
CFLAGS+=-I../libowfat -Wall -pipe -O2
|
||||
LDFLAGS+=-L../libowfat/ -lowfat -s
|
||||
|
||||
SOURCES=opentracker.c trackerlogic.c scan_urlencoded_query.c
|
||||
|
||||
|
@ -110,7 +110,22 @@ int vector_remove_torrent( ot_vector vector, ot_hash *hash ) {
|
||||
}
|
||||
|
||||
void clean_peerlist( ot_peerlist peer_list ) {
|
||||
exit( 1 );
|
||||
long timedout = NOW-peer_list->base;
|
||||
int i;
|
||||
|
||||
if( !timedout ) return;
|
||||
if( timedout > OT_POOLS_COUNT ) timedout = OT_POOLS_COUNT;
|
||||
|
||||
for( i=OT_POOLS_COUNT-timedout; i<OT_POOLS_COUNT; ++i )
|
||||
free( peer_list->peers[i].data);
|
||||
|
||||
MEMMOVE( peer_list->peers + timedout, peer_list->peers, sizeof( ot_vector ) * (OT_POOLS_COUNT-timedout) );
|
||||
byte_zero( peer_list->peers, sizeof( ot_vector ) * timedout );
|
||||
|
||||
MEMMOVE( peer_list->seed_count + timedout, peer_list->seed_count, sizeof( unsigned long ) * (OT_POOLS_COUNT-timedout) );
|
||||
byte_zero( peer_list->seed_count, sizeof( unsigned long ) * timedout );
|
||||
|
||||
peer_list->base = NOW;
|
||||
}
|
||||
|
||||
ot_torrent add_peer_to_torrent( ot_hash *hash, ot_peer peer ) {
|
||||
|
@ -20,7 +20,6 @@ typedef time_t ot_time;
|
||||
#define FORMAT_FIXED_STRING sprintf
|
||||
#define FORMAT_FORMAT_STRING sprintf
|
||||
#define BINARY_FIND binary_search
|
||||
#define NOW time(NULL)
|
||||
|
||||
// We maintain a list of 256 pointers to sorted list of ot_torrent structs
|
||||
// Sort key is, of course, its hash
|
||||
@ -31,6 +30,7 @@ typedef time_t ot_time;
|
||||
|
||||
#define OT_POOLS_COUNT 9
|
||||
#define OT_POOLS_TIMEOUT 300
|
||||
#define NOW (time(NULL)/OT_POOLS_TIMEOUT)
|
||||
|
||||
typedef struct ot_vector {
|
||||
void *data;
|
||||
|
Loading…
Reference in New Issue
Block a user