summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2007-01-27 16:06:13 +0000
committererdgeist <>2007-01-27 16:06:13 +0000
commitc094695add94493ab46d535b6fca1801efa127c2 (patch)
tree6dd0f7ee88c5a4a2951a44f9f7f2bd873880b22f
parent65675cd4daf5c5d26b13e32d1a8779aa8b689f88 (diff)
account downloaded before early returns
-rw-r--r--README6
-rw-r--r--README_v66
-rw-r--r--opentracker.c4
-rw-r--r--scan_urlencoded_query.c2
-rw-r--r--scan_urlencoded_query.h2
-rw-r--r--trackerlogic.c11
-rw-r--r--trackerlogic.h4
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
15make 15make
16./opentracker 16./opentracker
17 17
18This 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 18This 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
19-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 19-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
20essential 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 20essential 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
21more of our testsuite.sh script). 21more of our testsuite.sh script).
22 22
23Some tweaks you may want to try under FreeBSD: 23Some 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 @@
1Q: Why is there no v6-support in opentracker? 1Q: Why is there no v6-support in opentracker?
2 2
3A: 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 3A: 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
4answering "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 4answering "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
5compact mode, v6 addresses still would eat up thrice the memory, v4 addresses take. This, however, wouldn't be a show stopper. 5compact mode, v6 addresses still would eat up thrice the memory, v4 addresses take. This, however, wouldn't be a show stopper.
6 6
7Other 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 7Other 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
8host, too ;) 8host, 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:
285 /* Enough for http header + whole scrape string */ 285 /* Enough for http header + whole scrape string */
286 if( ( reply_size = return_scrape_for_torrent( hash, SUCCESS_HTTP_HEADER_LENGTH + static_scratch ) ) <= 0 ) HTTPERROR_500; 286 if( ( reply_size = return_scrape_for_torrent( hash, SUCCESS_HTTP_HEADER_LENGTH + static_scratch ) ) <= 0 ) HTTPERROR_500;
287 break; 287 break;
288 case 8: 288 case 8:
289 if( byte_diff(data,8,"announce")) HTTPERROR_404; 289 if( byte_diff(data,8,"announce")) HTTPERROR_404;
290 290
291ANNOUNCE_WORKAROUND: 291ANNOUNCE_WORKAROUND:
@@ -383,7 +383,7 @@ ANNOUNCE_WORKAROUND:
383 if( byte_diff(data,11,"mrtg_scrape")) HTTPERROR_404; 383 if( byte_diff(data,11,"mrtg_scrape")) HTTPERROR_404;
384 384
385 t = time( NULL ) - ot_start_time; 385 t = time( NULL ) - ot_start_time;
386 reply_size = sprintf( static_scratch + SUCCESS_HTTP_HEADER_LENGTH, 386 reply_size = sprintf( static_scratch + SUCCESS_HTTP_HEADER_LENGTH,
387 "%i\n%i\nUp: %i seconds (%i hours)\nPretuned by german engineers, currently handling %i connections per second.", 387 "%i\n%i\nUp: %i seconds (%i hours)\nPretuned by german engineers, currently handling %i connections per second.",
388 ot_overall_connections, ot_overall_successfulannounces, (int)t, (int)(t / 3600), (int)ot_overall_connections / ( (int)t ? (int)t : 1 ) ); 388 ot_overall_connections, ot_overall_successfulannounces, (int)t, (int)(t / 3600), (int)ot_overall_connections / ( (int)t ? (int)t : 1 ) );
389 break; 389 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 @@
1/* This software was written by Dirk Engling <erdgeist@erdgeist.org> 1/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever. */ 2 It is considered beerware. Prost. Skol. Cheers or whatever. */
3 3
4#include "scan.h" 4#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 @@
1/* This software was written by Dirk Engling <erdgeist@erdgeist.org> 1/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever. */ 2 It is considered beerware. Prost. Skol. Cheers or whatever. */
3 3
4#ifndef __SCAN_URLENCODED_QUERY_H__ 4#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 ) {
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;
diff --git a/trackerlogic.h b/trackerlogic.h
index 083c437..a3335f3 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -1,4 +1,4 @@
1/* This software was written by Dirk Engling <erdgeist@erdgeist.org> 1/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever. */ 2 It is considered beerware. Prost. Skol. Cheers or whatever. */
3 3
4#ifndef __TRACKERLOGIC_H__ 4#ifndef __TRACKERLOGIC_H__
@@ -44,7 +44,7 @@ typedef time_t ot_time;
44typedef struct { 44typedef struct {
45 void *data; 45 void *data;
46 size_t size; 46 size_t size;
47 size_t space; 47 size_t space;
48} ot_vector; 48} ot_vector;
49 49
50typedef struct { 50typedef struct {