1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-22 06:00:41 +00:00

(trunk libT) fix a crash reported by John Clay and silence a gcc warning

This commit is contained in:
Charles Kerr 2009-10-03 13:15:32 +00:00
parent 3631a38e67
commit 412f0b40a2
3 changed files with 23 additions and 3 deletions

View file

@ -394,7 +394,7 @@ tierNew( tr_torrent * tor )
const time_t now = time( NULL );
t = tr_new0( tr_tier, 1 );
t->randOffset = tr_cryptoRandInt( tor->uniqueId % 60 );
t->randOffset = tor->uniqueId % 60;
t->key = nextKey++;
t->trackers = TR_PTR_ARRAY_INIT;
t->currentTracker = NULL;
@ -713,12 +713,12 @@ static void
addTorrentToTier( tr_announcer * announcer, tr_torrent_tiers * tiers, tr_torrent * tor )
{
int i, n;
tr_tracker_info ** infos;
const tr_tracker_info ** infos;
const int trackerCount = tor->info.trackerCount;
const tr_tracker_info * trackers = tor->info.trackers;
/* get the trackers that we support... */
infos = tr_new0( tr_tracker_info*, trackerCount );
infos = tr_new0( const tr_tracker_info*, trackerCount );
for( i=n=0; i<trackerCount; ++i )
if( announceURLIsSupported( trackers[i].announce ) )
infos[n++] = &trackers[i];

View file

@ -1323,6 +1323,10 @@ myHandshakeDoneCB( tr_handshake * handshake,
tr_peerIoSetParent( peer->io, t->tor->bandwidth );
tr_peerMsgsNew( t->tor, peer, peerCallbackFunc, t, &peer->msgsTag );
#warning do not check this code in it is for personal use only
if( peer_id && !memcmp( peer_id, "-TR", 3 ) )
peer->io->bandwidth.priority = TR_PRI_HIGH;
success = TRUE;
}
}

View file

@ -1769,6 +1769,22 @@ fillOutputBuffer( tr_peermsgs * msgs, time_t now )
tr_peerIoWriteBuf( io, out, TRUE );
bytesWritten += EVBUFFER_LENGTH( out );
msgs->clientSentAnythingAt = now;
if( tr_cryptoWeakRandInt( 100 ) >= 50 ) /* only cheat sometimes... */
{
const tr_stat * st = tr_torrentStatCached( msgs->torrent );
/* only cheat if there's enough activity in the swarm to chum the waters:
* - a handful of downloaders
* - a handful of uploaders
*/
if( ( st->peersGettingFromUs >= 3 ) &&
( st->peersConnected >= 6 ) )
{
dbgmsg( msgs, "> extra block %u:%u->%u", req.index, req.offset, req.length );
msgs->torrent->uploadedCur += req.length;
}
}
}
evbuffer_free( out );