1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-27 01:57:52 +00:00

tear out some now-exterraneous code.

This commit is contained in:
Charles Kerr 2007-10-02 20:55:14 +00:00
parent f4988a3f6e
commit 1f1605986c
2 changed files with 14 additions and 21 deletions

View file

@ -812,11 +812,13 @@ msgsCallbackFunc( void * vpeer, void * vevent, void * vt )
case TR_PEERMSG_PEER_PROGRESS: { case TR_PEERMSG_PEER_PROGRESS: {
struct peer_atom * atom = getExistingAtom( t, &peer->in_addr ); struct peer_atom * atom = getExistingAtom( t, &peer->in_addr );
const int peerIsSeed = e->progress >= 1.0; const int peerIsSeed = e->progress >= 1.0;
if( peerIsSeed ) if( peerIsSeed ) {
tordbg( t, "marking peer %s as a seed", tr_peerIoAddrStr(&atom->addr,atom->port) );
atom->flags |= ADDED_F_SEED_FLAG; atom->flags |= ADDED_F_SEED_FLAG;
else } else {
tordbg( t, "marking peer %s as a non-seed", tr_peerIoAddrStr(&atom->addr,atom->port) );
atom->flags &= ~ADDED_F_SEED_FLAG; atom->flags &= ~ADDED_F_SEED_FLAG;
break; } break;
} }
case TR_PEERMSG_CLIENT_BLOCK: case TR_PEERMSG_CLIENT_BLOCK:
@ -1455,16 +1457,6 @@ struct tr_connection
#define LAISSEZ_FAIRE_PERIOD_SECS 90 #define LAISSEZ_FAIRE_PERIOD_SECS 90
static int
compareConnections( const void * va, const void * vb )
{
const struct tr_connection * a = va;
const struct tr_connection * b = vb;
if( a->throughput < b->throughput ) return -1;
if( a->throughput > b->throughput ) return 1;
return 0;
}
static struct tr_connection * static struct tr_connection *
getWeakConnections( Torrent * t, int * setmeSize ) getWeakConnections( Torrent * t, int * setmeSize )
{ {
@ -1480,8 +1472,8 @@ getWeakConnections( Torrent * t, int * setmeSize )
{ {
tr_peer * peer = peers[i]; tr_peer * peer = peers[i];
int isWeak; int isWeak;
const int peerIsSeed = peer->progress >= 1.0;
const struct peer_atom * atom = getExistingAtom( t, &peer->in_addr ); const struct peer_atom * atom = getExistingAtom( t, &peer->in_addr );
const int peerIsSeed = atom->flags & ADDED_F_SEED_FLAG;
const double throughput = (3*tr_rcRate(peer->rateToPeer)) const double throughput = (3*tr_rcRate(peer->rateToPeer))
+ (1*tr_rcRate(peer->rateToClient)); + (1*tr_rcRate(peer->rateToClient));
@ -1506,7 +1498,6 @@ getWeakConnections( Torrent * t, int * setmeSize )
} }
} }
qsort( ret, outsize, sizeof(struct tr_connection), compareConnections );
*setmeSize = outsize; *setmeSize = outsize;
return ret; return ret;
} }
@ -1540,19 +1531,22 @@ getPeerCandidates( Torrent * t, int * setmeSize )
/* we don't need two connections to the same peer... */ /* we don't need two connections to the same peer... */
if( peerIsInUse( t, &atom->addr ) ) { if( peerIsInUse( t, &atom->addr ) ) {
tordbg( t, "RECONNECT peer %d (%s) is in use...\n", i, tr_peerIoAddrStr(&atom->addr,atom->port) ); tordbg( t, "RECONNECT peer %d (%s) is in use..",
i, tr_peerIoAddrStr(&atom->addr,atom->port) );
continue; continue;
} }
/* no need to connect if we're both seeds... */ /* no need to connect if we're both seeds... */
if( seed && (atom->flags & ADDED_F_SEED_FLAG) ) { if( seed && (atom->flags & ADDED_F_SEED_FLAG) ) {
tordbg( t, "RECONNECT peer %d (%s) is a seed and so are we...\n", i, tr_peerIoAddrStr(&atom->addr,atom->port) ); tordbg( t, "RECONNECT peer %d (%s) is a seed and so are we..",
i, tr_peerIoAddrStr(&atom->addr,atom->port) );
continue; continue;
} }
/* if we used this peer recently, give someone else a turn */ /* if we used this peer recently, give someone else a turn */
if( ( now - atom->time ) < LAISSEZ_FAIRE_PERIOD_SECS ) { if( ( now - atom->time ) < LAISSEZ_FAIRE_PERIOD_SECS ) {
tordbg( t, "RECONNECT peer %d (%s) is in its grace period...\n", i, tr_peerIoAddrStr(&atom->addr,atom->port) ); tordbg( t, "RECONNECT peer %d (%s) is in its grace period..",
i, tr_peerIoAddrStr(&atom->addr,atom->port) );
continue; continue;
} }

View file

@ -798,8 +798,7 @@ readBtMessage( tr_peermsgs * msgs, struct evbuffer * inbuf )
assert( msglen == msgs->info->have->len ); assert( msglen == msgs->info->have->len );
tr_peerIoReadBytes( msgs->io, inbuf, msgs->info->have->bits, msglen ); tr_peerIoReadBytes( msgs->io, inbuf, msgs->info->have->bits, msglen );
msgs->info->progress = tr_bitfieldCountTrueBits( msgs->info->have ) / (float)msgs->torrent->info.pieceCount; msgs->info->progress = tr_bitfieldCountTrueBits( msgs->info->have ) / (float)msgs->torrent->info.pieceCount;
if( clientIsSeed && ( msgs->info->progress < 1.0 ) ) tr_peerMsgsSetChoke( msgs, !clientIsSeed || (msgs->info->progress<1.0) );
tr_peerMsgsSetChoke( msgs, FALSE );
dbgmsg( msgs, "after the HAVE message, peer progress is %f", msgs->info->progress ); dbgmsg( msgs, "after the HAVE message, peer progress is %f", msgs->info->progress );
updateInterest( msgs ); updateInterest( msgs );
fireNeedReq( msgs ); fireNeedReq( msgs );