summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2008-12-01 17:56:53 +0000
committererdgeist <>2008-12-01 17:56:53 +0000
commit566e8267e15032dfd9f12320c83deee4d74d13cb (patch)
treeb8078d5688d68272d785e5491c27a28a68ea782b
parent334c6e4bbb97a4c0656e1b07c3e6a565f68eae2b (diff)
Live Sync for peers that do not come back too early.
-rw-r--r--trackerlogic.c10
-rw-r--r--trackerlogic.h3
2 files changed, 13 insertions, 0 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index faca19b..05c00b0 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -103,6 +103,16 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
103 } else { 103 } else {
104 stats_issue_event( EVENT_RENEW, 0, OT_PEERTIME( peer_dest ) ); 104 stats_issue_event( EVENT_RENEW, 0, OT_PEERTIME( peer_dest ) );
105 105
106#ifdef WANT_SYNC_LIVE
107 /* Won't live sync peers that come back too fast. Only exception:
108 fresh "completed" reports */
109 if( !from_sync ) {
110 if( OT_PEERTIME( peer_dest ) > OT_CLIENT_SYNC_RENEW_BOUNDARY ||
111 ( !(OT_FLAG(peer_dest) & PEER_FLAG_COMPLETED ) && (OT_FLAG(peer) & PEER_FLAG_COMPLETED ) ) )
112 livesync_tell( hash, peer );
113 }
114#endif
115
106 if( (OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && !(OT_FLAG(peer) & PEER_FLAG_SEEDING ) ) 116 if( (OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && !(OT_FLAG(peer) & PEER_FLAG_SEEDING ) )
107 torrent->peer_list->seed_count--; 117 torrent->peer_list->seed_count--;
108 if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) ) 118 if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) )
diff --git a/trackerlogic.h b/trackerlogic.h
index c2d071a..0b73d5e 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -26,6 +26,9 @@ typedef time_t ot_time;
26 26
27#define OT_CLIENT_REQUEST_INTERVAL_RANDOM ( OT_CLIENT_REQUEST_INTERVAL - OT_CLIENT_REQUEST_VARIATION/2 + (int)( random( ) % OT_CLIENT_REQUEST_VARIATION ) ) 27#define OT_CLIENT_REQUEST_INTERVAL_RANDOM ( OT_CLIENT_REQUEST_INTERVAL - OT_CLIENT_REQUEST_VARIATION/2 + (int)( random( ) % OT_CLIENT_REQUEST_VARIATION ) )
28 28
29/* If peers come back before 10 minutes, don't live sync them */
30#define OT_CLIENT_SYNC_RENEW_BOUNDARY 10
31
29/* We maintain a list of 1024 pointers to sorted list of ot_torrent structs 32/* We maintain a list of 1024 pointers to sorted list of ot_torrent structs
30 Sort key is, of course, its hash */ 33 Sort key is, of course, its hash */
31#define OT_BUCKET_COUNT 1024 34#define OT_BUCKET_COUNT 1024