Changeset 9230 for trunk/libtransmission/announcer.c
- Timestamp:
- Oct 2, 2009, 4:54:02 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/announcer.c
r9229 r9230 290 290 /* sent as the "key" argument in tracker requests 291 291 * to verify us if our IP address changes. 292 * This is immutable for the life of the tracker object. */ 292 * This is immutable for the life of the tracker object. 293 * The +1 is for '\0' */ 293 294 char key_param[KEYLEN + 1]; 294 295 } … … 394 395 395 396 t = tr_new0( tr_tier, 1 ); 396 t->randOffset = tr_cryptoRandInt( 60 );397 t->randOffset = tr_cryptoRandInt( tor->uniqueId % 60 ); 397 398 t->key = nextKey++; 398 399 t->trackers = TR_PTR_ARRAY_INIT; … … 474 475 tiers->publisher = TR_PUBLISHER_INIT; 475 476 return tiers; 477 } 478 479 static void 480 tiersClear( tr_torrent_tiers * tiers ) 481 { 482 tr_ptrArrayDestruct( &tiers->tiers, tierFree ); 483 tiers->tiers = TR_PTR_ARRAY_INIT; 476 484 } 477 485 … … 702 710 } 703 711 704 tr_torrent_tiers * 705 tr_announcerAddTorrent( tr_announcer * announcer, tr_torrent * tor )712 static void 713 addTorrentToTier( tr_announcer * announcer, tr_torrent_tiers * tiers, tr_torrent * tor ) 706 714 { 707 715 int i, n; 708 tr_torrent_tiers * tiers;709 716 tr_tracker_info ** infos; 717 const int trackerCount = tor->info.trackerCount; 718 const tr_tracker_info * trackers = tor->info.trackers; 710 719 711 720 /* get the trackers that we support... */ 712 infos = tr_new( tr_tracker_info*, tor->info.trackerCount ); 713 for( i=n=0; i<tor->info.trackerCount; ++i ) 714 if( announceURLIsSupported( tor->info.trackers[i].announce ) ) 715 infos[n++] = &tor->info.trackers[i]; 716 717 assert( announcer != NULL ); 718 assert( tr_isTorrent( tor ) ); 719 720 tiers = tiersNew( ); 721 infos = tr_new0( tr_tracker_info*, trackerCount ); 722 for( i=n=0; i<trackerCount; ++i ) 723 if( announceURLIsSupported( trackers[i].announce ) ) 724 infos[n++] = &trackers[i]; 721 725 722 726 /* build our private table of tiers... */ … … 726 730 tr_tier * tier = NULL; 727 731 728 for( i=0; i<t or->info.trackerCount; ++i )732 for( i=0; i<trackerCount; ++i ) 729 733 { 730 734 const tr_tracker_info * info = infos[i]; … … 746 750 747 751 tr_free( infos ); 752 } 753 754 tr_torrent_tiers * 755 tr_announcerAddTorrent( tr_announcer * announcer, tr_torrent * tor ) 756 { 757 tr_torrent_tiers * tiers; 758 759 assert( announcer != NULL ); 760 assert( tr_isTorrent( tor ) ); 761 762 tiers = tiersNew( ); 763 764 addTorrentToTier( announcer, tiers, tor ); 765 748 766 return tiers; 767 } 768 769 void 770 tr_announcerResetTorrent( tr_announcer * announcer, tr_torrent * tor ) 771 { 772 if( tor->tiers != NULL ) 773 { 774 tiersClear( tor->tiers ); 775 776 addTorrentToTier( announcer, tor->tiers, tor ); 777 } 749 778 } 750 779
Note: See TracChangeset
for help on using the changeset viewer.