summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2008-12-03 20:40:50 +0000
committererdgeist <>2008-12-03 20:40:50 +0000
commiteda3ae7f91c9c844f6a8cd6114db9e223587de5e (patch)
treee1b3bcde236381a0e2d2ceafa4b8a1400d22be90
parent2c7c10138bb2c990b0248b805ea282f7f159dc89 (diff)
Add debug code to spot peers that come back too early
-rw-r--r--trackerlogic.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index 05c00b0..b418de4 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -38,6 +38,11 @@ void free_peerlist( ot_peerlist *peer_list ) {
38 free( peer_list ); 38 free( peer_list );
39} 39}
40 40
41#ifdef _DEBUG_PEERID
42extern size_t g_this_peerid_len;
43extern char *g_this_peerid_data;
44#endif
45
41ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM( int from_sync ) ) { 46ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM( int from_sync ) ) {
42 int exactmatch; 47 int exactmatch;
43 ot_torrent *torrent; 48 ot_torrent *torrent;
@@ -66,12 +71,10 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
66 } 71 }
67 72
68 byte_zero( torrent->peer_list, sizeof( ot_peerlist ) ); 73 byte_zero( torrent->peer_list, sizeof( ot_peerlist ) );
74 torrent->peer_list->base = g_now_minutes;
69 } else 75 } else
70 clean_single_torrent( torrent ); 76 clean_single_torrent( torrent );
71 77
72 /* Timestamp our first pool */
73 torrent->peer_list->base = g_now_minutes;
74
75 /* Check for peer in torrent */ 78 /* Check for peer in torrent */
76 peer_dest = vector_find_or_insert_peer( &(torrent->peer_list->peers), peer, &exactmatch ); 79 peer_dest = vector_find_or_insert_peer( &(torrent->peer_list->peers), peer, &exactmatch );
77 if( !peer_dest ) { 80 if( !peer_dest ) {
@@ -92,6 +95,8 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
92#ifdef WANT_SYNC_LIVE 95#ifdef WANT_SYNC_LIVE
93 if( !from_sync ) 96 if( !from_sync )
94 livesync_tell( hash, peer ); 97 livesync_tell( hash, peer );
98 else
99 OT_FLAG( peer ) |= PEER_FLAG_FROM_SYNC;
95#endif 100#endif
96 101
97 torrent->peer_list->peer_count++; 102 torrent->peer_list->peer_count++;
@@ -103,6 +108,17 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
103 } else { 108 } else {
104 stats_issue_event( EVENT_RENEW, 0, OT_PEERTIME( peer_dest ) ); 109 stats_issue_event( EVENT_RENEW, 0, OT_PEERTIME( peer_dest ) );
105 110
111#ifdef _DEBUG_PEERID
112 if( OT_PEERTIME( peer_dest ) < 2 ) {
113 uint8_t *_ip = (uint8_t*)peer_dest;
114 int i;
115 for( i=0;i<20;++i)printf("%02X",(*hash)[i]);
116 printf( " %d.%d.%d.%d:%d\t%d %02X ", _ip[0], _ip[1], _ip[2], _ip[3], OT_PEERTIME( peer_dest ), OT_PEERTIME( peer_dest ), OT_FLAG(peer_dest));
117 if( g_this_peerid_len ) write( 1, g_this_peerid_data, g_this_peerid_len );
118 putchar(10);
119 }
120#endif
121
106#ifdef WANT_SYNC_LIVE 122#ifdef WANT_SYNC_LIVE
107 /* Won't live sync peers that come back too fast. Only exception: 123 /* Won't live sync peers that come back too fast. Only exception:
108 fresh "completed" reports */ 124 fresh "completed" reports */