From c094695add94493ab46d535b6fca1801efa127c2 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Sat, 27 Jan 2007 16:06:13 +0000 Subject: account downloaded before early returns --- README | 6 +++--- README_v6 | 6 +++--- opentracker.c | 4 ++-- scan_urlencoded_query.c | 2 +- scan_urlencoded_query.h | 2 +- trackerlogic.c | 11 ++++++----- trackerlogic.h | 4 ++-- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/README b/README index 1890400..8fac50b 100644 --- a/README +++ b/README @@ -15,9 +15,9 @@ cd opentracker-1.0 make ./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 --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 +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 +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). Some tweaks you may want to try under FreeBSD: diff --git a/README_v6 b/README_v6 index 72d25a3..6a5a82a 100644 --- a/README_v6 +++ b/README_v6 @@ -1,8 +1,8 @@ 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 -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 +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 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 ;) diff --git a/opentracker.c b/opentracker.c index f69ae70..e415cc3 100644 --- a/opentracker.c +++ b/opentracker.c @@ -285,7 +285,7 @@ SCRAPE_WORKAROUND: /* Enough for http header + whole scrape string */ if( ( reply_size = return_scrape_for_torrent( hash, SUCCESS_HTTP_HEADER_LENGTH + static_scratch ) ) <= 0 ) HTTPERROR_500; break; - case 8: + case 8: if( byte_diff(data,8,"announce")) HTTPERROR_404; ANNOUNCE_WORKAROUND: @@ -383,7 +383,7 @@ ANNOUNCE_WORKAROUND: if( byte_diff(data,11,"mrtg_scrape")) HTTPERROR_404; 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.", ot_overall_connections, ot_overall_successfulannounces, (int)t, (int)(t / 3600), (int)ot_overall_connections / ( (int)t ? (int)t : 1 ) ); break; diff --git a/scan_urlencoded_query.c b/scan_urlencoded_query.c index ff38246..dc43b61 100644 --- a/scan_urlencoded_query.c +++ b/scan_urlencoded_query.c @@ -1,4 +1,4 @@ -/* This software was written by Dirk Engling +/* This software was written by Dirk Engling It is considered beerware. Prost. Skol. Cheers or whatever. */ #include "scan.h" diff --git a/scan_urlencoded_query.h b/scan_urlencoded_query.h index 7663278..e20cbef 100644 --- a/scan_urlencoded_query.h +++ b/scan_urlencoded_query.h @@ -1,4 +1,4 @@ -/* This software was written by Dirk Engling +/* This software was written by Dirk Engling It is considered beerware. Prost. Skol. Cheers or whatever. */ #ifndef __SCAN_URLENCODED_QUERY_H__ 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 ) { 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 ); + 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 remove it from all older pools */ 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 ) ) torrent->peer_list->seed_count[0]++; } - if( OT_FLAG(peer) & PEER_FLAG_COMPLETED ) - torrent->peer_list->downloaded++; return torrent; } @@ -435,13 +436,13 @@ void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ) { int exactmatch, i; 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 ); - + if( !exactmatch ) return; - + /* Maybe this does the job */ if( clean_peerlist( NOW, torrent->peer_list ) ) { #ifdef WANT_CLOSED_TRACKER - if( !g_closedtracker ) + if( !g_closedtracker ) #endif vector_remove_torrent( torrents_list, hash ); return; diff --git a/trackerlogic.h b/trackerlogic.h index 083c437..a3335f3 100644 --- a/trackerlogic.h +++ b/trackerlogic.h @@ -1,4 +1,4 @@ -/* This software was written by Dirk Engling +/* This software was written by Dirk Engling It is considered beerware. Prost. Skol. Cheers or whatever. */ #ifndef __TRACKERLOGIC_H__ @@ -44,7 +44,7 @@ typedef time_t ot_time; typedef struct { void *data; size_t size; - size_t space; + size_t space; } ot_vector; typedef struct { -- cgit v1.2.3