1
0
mirror of git://erdgeist.org/opentracker synced 2025-02-09 13:36:24 +00:00

account downloaded before early returns

This commit is contained in:
erdgeist 2007-01-27 16:06:13 +00:00
parent 65675cd4da
commit c094695add
7 changed files with 18 additions and 17 deletions

6
README
View File

@ -15,9 +15,9 @@ cd opentracker-1.0
make make
./opentracker ./opentracker
This tracker is open in a sense that everyone announcing a torrent is welcome to do so and will be informed about anyone else announcing the same torrent. Unless This tracker is open in a sense that everyone announcing a torrent is welcome to do so and will be informed about anyone else announcing the same torrent. Unless
-DWANT_IP_FROM_QUERY_STRING is enabled (which is meant for debugging purposes only), only source IPs are accepted. The tracker implements a minimal set of -DWANT_IP_FROM_QUERY_STRING is enabled (which is meant for debugging purposes only), only source IPs are accepted. The tracker implements a minimal set of
essential features only but was able respond to far more than 10000 requests per second on a Sun Fire 2200 M2 (thats where we found no more clients able to fire essential features only but was able respond to far more than 10000 requests per second on a Sun Fire 2200 M2 (thats where we found no more clients able to fire
more of our testsuite.sh script). more of our testsuite.sh script).
Some tweaks you may want to try under FreeBSD: Some tweaks you may want to try under FreeBSD:

View File

@ -1,8 +1,8 @@
Q: Why is there no v6-support in opentracker? Q: Why is there no v6-support in opentracker?
A: Although I tried very hard, implementing v6 right now would be a terrible waste of bandwidth, there is no compact format for v6 addresses, so instead of A: Although I tried very hard, implementing v6 right now would be a terrible waste of bandwidth, there is no compact format for v6 addresses, so instead of
answering "d5:peers6:AAAAPPe" I'd have to send "d5:peersld2:ip39:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA4:port2:PPPPeee" for a single peer. Even if there was a answering "d5:peers6:AAAAPPe" I'd have to send "d5:peersld2:ip39:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA4:port2:PPPPeee" for a single peer. Even if there was a
compact mode, v6 addresses still would eat up thrice the memory, v4 addresses take. This, however, wouldn't be a show stopper. compact mode, v6 addresses still would eat up thrice the memory, v4 addresses take. This, however, wouldn't be a show stopper.
Other problems concern efficient peer selection for obviously v6-capable peers and how to select peers for non-v6 clients. v6 addresses eat up more memory on the Other problems concern efficient peer selection for obviously v6-capable peers and how to select peers for non-v6 clients. v6 addresses eat up more memory on the
host, too ;) host, too ;)

View File

@ -285,7 +285,7 @@ SCRAPE_WORKAROUND:
/* Enough for http header + whole scrape string */ /* Enough for http header + whole scrape string */
if( ( reply_size = return_scrape_for_torrent( hash, SUCCESS_HTTP_HEADER_LENGTH + static_scratch ) ) <= 0 ) HTTPERROR_500; if( ( reply_size = return_scrape_for_torrent( hash, SUCCESS_HTTP_HEADER_LENGTH + static_scratch ) ) <= 0 ) HTTPERROR_500;
break; break;
case 8: case 8:
if( byte_diff(data,8,"announce")) HTTPERROR_404; if( byte_diff(data,8,"announce")) HTTPERROR_404;
ANNOUNCE_WORKAROUND: ANNOUNCE_WORKAROUND:
@ -383,7 +383,7 @@ ANNOUNCE_WORKAROUND:
if( byte_diff(data,11,"mrtg_scrape")) HTTPERROR_404; if( byte_diff(data,11,"mrtg_scrape")) HTTPERROR_404;
t = time( NULL ) - ot_start_time; t = time( NULL ) - ot_start_time;
reply_size = sprintf( static_scratch + SUCCESS_HTTP_HEADER_LENGTH, reply_size = sprintf( static_scratch + SUCCESS_HTTP_HEADER_LENGTH,
"%i\n%i\nUp: %i seconds (%i hours)\nPretuned by german engineers, currently handling %i connections per second.", "%i\n%i\nUp: %i seconds (%i hours)\nPretuned by german engineers, currently handling %i connections per second.",
ot_overall_connections, ot_overall_successfulannounces, (int)t, (int)(t / 3600), (int)ot_overall_connections / ( (int)t ? (int)t : 1 ) ); ot_overall_connections, ot_overall_successfulannounces, (int)t, (int)(t / 3600), (int)ot_overall_connections / ( (int)t ? (int)t : 1 ) );
break; break;

View File

@ -1,4 +1,4 @@
/* This software was written by Dirk Engling <erdgeist@erdgeist.org> /* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever. */ It is considered beerware. Prost. Skol. Cheers or whatever. */
#include "scan.h" #include "scan.h"

View File

@ -1,4 +1,4 @@
/* This software was written by Dirk Engling <erdgeist@erdgeist.org> /* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever. */ It is considered beerware. Prost. Skol. Cheers or whatever. */
#ifndef __SCAN_URLENCODED_QUERY_H__ #ifndef __SCAN_URLENCODED_QUERY_H__

View File

@ -195,6 +195,9 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) {
peer_pool = &torrent->peer_list->peers[0]; peer_pool = &torrent->peer_list->peers[0];
peer_dest = vector_find_or_insert( peer_pool, (void*)peer, sizeof( ot_peer ), OT_PEER_COMPARE_SIZE, &exactmatch ); peer_dest = vector_find_or_insert( peer_pool, (void*)peer, sizeof( ot_peer ), OT_PEER_COMPARE_SIZE, &exactmatch );
if( OT_FLAG(peer) & PEER_FLAG_COMPLETED )
torrent->peer_list->downloaded++;
/* If we hadn't had a match in current pool, create peer there and /* If we hadn't had a match in current pool, create peer there and
remove it from all older pools */ remove it from all older pools */
if( !exactmatch ) { if( !exactmatch ) {
@ -215,8 +218,6 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) {
if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) ) if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) )
torrent->peer_list->seed_count[0]++; torrent->peer_list->seed_count[0]++;
} }
if( OT_FLAG(peer) & PEER_FLAG_COMPLETED )
torrent->peer_list->downloaded++;
return torrent; return torrent;
} }
@ -435,13 +436,13 @@ void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ) {
int exactmatch, i; int exactmatch, i;
ot_vector *torrents_list = &all_torrents[*hash[0]]; ot_vector *torrents_list = &all_torrents[*hash[0]];
ot_torrent *torrent = binary_search( hash, torrents_list->data, torrents_list->size, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch ); ot_torrent *torrent = binary_search( hash, torrents_list->data, torrents_list->size, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch );
if( !exactmatch ) return; if( !exactmatch ) return;
/* Maybe this does the job */ /* Maybe this does the job */
if( clean_peerlist( NOW, torrent->peer_list ) ) { if( clean_peerlist( NOW, torrent->peer_list ) ) {
#ifdef WANT_CLOSED_TRACKER #ifdef WANT_CLOSED_TRACKER
if( !g_closedtracker ) if( !g_closedtracker )
#endif #endif
vector_remove_torrent( torrents_list, hash ); vector_remove_torrent( torrents_list, hash );
return; return;

View File

@ -1,4 +1,4 @@
/* This software was written by Dirk Engling <erdgeist@erdgeist.org> /* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever. */ It is considered beerware. Prost. Skol. Cheers or whatever. */
#ifndef __TRACKERLOGIC_H__ #ifndef __TRACKERLOGIC_H__
@ -44,7 +44,7 @@ typedef time_t ot_time;
typedef struct { typedef struct {
void *data; void *data;
size_t size; size_t size;
size_t space; size_t space;
} ot_vector; } ot_vector;
typedef struct { typedef struct {