mirror of
				git://erdgeist.org/opentracker
				synced 2025-11-04 11:53:22 +08:00 
			
		
		
		
	Live Sync for peers that do not come back too early.
This commit is contained in:
		
							parent
							
								
									334c6e4bbb
								
							
						
					
					
						commit
						566e8267e1
					
				@ -103,6 +103,16 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer  WANT_SYNC_PARAM(
 | 
				
			|||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    stats_issue_event( EVENT_RENEW, 0, OT_PEERTIME( peer_dest ) );
 | 
					    stats_issue_event( EVENT_RENEW, 0, OT_PEERTIME( peer_dest ) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef WANT_SYNC_LIVE
 | 
				
			||||||
 | 
					    /* Won't live sync peers that come back too fast. Only exception:
 | 
				
			||||||
 | 
					       fresh "completed" reports */
 | 
				
			||||||
 | 
					    if( !from_sync ) {
 | 
				
			||||||
 | 
					      if( OT_PEERTIME( peer_dest ) > OT_CLIENT_SYNC_RENEW_BOUNDARY ||
 | 
				
			||||||
 | 
					         ( !(OT_FLAG(peer_dest) & PEER_FLAG_COMPLETED ) && (OT_FLAG(peer) & PEER_FLAG_COMPLETED ) ) )
 | 
				
			||||||
 | 
					        livesync_tell( hash, peer );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    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--;
 | 
					      torrent->peer_list->seed_count--;
 | 
				
			||||||
    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 ) )
 | 
				
			||||||
 | 
				
			|||||||
@ -26,6 +26,9 @@ typedef time_t         ot_time;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define OT_CLIENT_REQUEST_INTERVAL_RANDOM ( OT_CLIENT_REQUEST_INTERVAL - OT_CLIENT_REQUEST_VARIATION/2 + (int)( random( ) % OT_CLIENT_REQUEST_VARIATION ) )
 | 
					#define OT_CLIENT_REQUEST_INTERVAL_RANDOM ( OT_CLIENT_REQUEST_INTERVAL - OT_CLIENT_REQUEST_VARIATION/2 + (int)( random( ) % OT_CLIENT_REQUEST_VARIATION ) )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* If peers come back before 10 minutes, don't live sync them */
 | 
				
			||||||
 | 
					#define OT_CLIENT_SYNC_RENEW_BOUNDARY 10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* We maintain a list of 1024 pointers to sorted list of ot_torrent structs
 | 
					/* We maintain a list of 1024 pointers to sorted list of ot_torrent structs
 | 
				
			||||||
   Sort key is, of course, its hash */
 | 
					   Sort key is, of course, its hash */
 | 
				
			||||||
#define OT_BUCKET_COUNT 1024
 | 
					#define OT_BUCKET_COUNT 1024
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user