Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cfpp2p committed Jun 2, 2017
1 parent fd4c044 commit 9bcbada
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions libtransmission/announcer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,18 @@ multiscrape( tr_announcer * announcer, tr_ptrArray * tiers )
char * url = tier->currentTracker->scrape;
const uint8_t * hash = tier->tor->info.hash;

/* https://github.com/transmission/transmission/issues/297 is protected by announceMore( ) */
char name[128];
tier_build_log_name( tier, name, sizeof( name ) );
if( url == NULL )
{
/* so url == NULL should never be */
tr_dbg( " %s scrape url is NULL! tier index is %d .", name, i );
continue;
}
else
tr_dbg( " %s scrape url is \"%s\" . tier index is %d .", name, url, i );

/* if there's a request with this scrape URL and a free slot, use it */
for( j=0; j<request_count; ++j )
{
Expand Down Expand Up @@ -1625,8 +1637,6 @@ announceMore( tr_announcer * announcer )
tr_tier * tier = &tt->tiers[i];
if( tierNeedsToAnnounce( tier, now ) )
tr_ptrArrayAppend( &announceMe, tier );
else if( tierNeedsToScrape( tier, now ) )
tr_ptrArrayAppend( &scrapeMe, tier );
}
}

Expand All @@ -1644,6 +1654,17 @@ announceMore( tr_announcer * announcer )
tierAnnounce( announcer, tier );
}

/* build a list of tiers that need to be scraped */
tor = NULL;
while(( tor = tr_torrentNext( announcer->session, tor ))) {
struct tr_torrent_tiers * tt = tor->tiers;
for( i=0; tt && i<tt->tier_count; ++i ) {
tr_tier * tier = &tt->tiers[i];
if( !tierNeedsToAnnounce( tier, now ) && tierNeedsToScrape( tier, now ) )
tr_ptrArrayAppend( &scrapeMe, tier );
}
}

/* scrape some */
multiscrape( announcer, &scrapeMe );

Expand Down

2 comments on commit 9bcbada

@cfpp2p
Copy link
Owner

@cfpp2p cfpp2p commented on 9bcbada Jun 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kralcyor Thanks!

@cfpp2p
Copy link
Owner

@cfpp2p cfpp2p commented on 9bcbada Jun 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIXED: request->url could be NULL(0x0) in scrape_request_delegate()

Please sign in to comment.