Changeset 4608
- Timestamp:
- Jan 11, 2008, 2:09:20 AM (14 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-io.c
r4600 r4608 59 59 struct bufferevent * bufev; 60 60 uint8_t peerId[20]; 61 time_t timeCreated; 61 62 62 63 tr_extensions extensions; … … 147 148 c->isIncoming = isIncoming ? 1 : 0; 148 149 c->timeout = IO_TIMEOUT_SECS; 150 c->timeCreated = time( NULL ); 149 151 c->bufev = bufferevent_new( c->socket, 150 152 canReadWrapper, … … 583 585 tr_free( tmp ); 584 586 } 587 588 int 589 tr_peerGetAge( const tr_peerIo * io ) 590 { 591 return time( NULL ) - io->timeCreated; 592 } -
trunk/libtransmission/peer-io.h
r4404 r4608 81 81 int tr_peerIoIsIncoming( const tr_peerIo * io ); 82 82 83 void tr_peerIoSetTimeoutSecs( tr_peerIo * io, int secs ); 83 void tr_peerIoSetTimeoutSecs( tr_peerIo * io, int secs ); 84 85 int tr_peerIoGetAge( const tr_peerIo * io ); 84 86 85 87 -
trunk/libtransmission/peer-mgr.c
r4605 r4608 141 141 tr_timer * swiftTimer; 142 142 tr_torrent * tor; 143 tr_peer * optimistic; /* the optimistic peer, or NULL if none */ 143 144 tr_bitfield * requested; 144 145 … … 1481 1482 1482 1483 pch = stat->flagStr; 1484 if( t->optimistic == peer ) *pch++ = 'O'; 1483 1485 if( stat->isDownloadingFrom ) *pch++ = 'D'; 1484 1486 else if( stat->clientIsInterested ) *pch++ = 'd'; … … 1518 1520 const struct ChokeData * b = vb; 1519 1521 return -tr_compareUint32( a->rate, b->rate ); 1522 } 1523 1524 static int 1525 isNew( const tr_peer * peer ) 1526 { 1527 return peer && peer->io && tr_peerIoGetAge( peer->io ) < 45; 1528 } 1529 1530 static int 1531 isSame( const tr_peer * peer ) 1532 { 1533 return peer && peer->client && strstr( peer->client, "Transmission" ); 1520 1534 } 1521 1535 … … 1581 1595 1582 1596 /* optimistic unchoke */ 1583 if( i != size ) { 1584 i = n + tr_rand( size - n ); 1585 choke[i].doUnchoke = 1; 1597 if( i < size ) 1598 { 1599 struct ChokeData * c; 1600 tr_ptrArray * randPool = tr_ptrArrayNew( ); 1601 for( ; i<size; ++i ) 1602 { 1603 const tr_peer * peer = choke[i].peer; 1604 int x=1, y; 1605 if( isNew( peer ) ) x *= 3; 1606 if( isSame( peer ) ) x *= 3; 1607 for( y=0; y<x; ++y ) 1608 tr_ptrArrayAppend( randPool, choke ); 1609 } 1610 i = tr_rand( tr_ptrArraySize( randPool ) ); 1611 c = ( struct ChokeData* )tr_ptrArrayNth( randPool, i); 1612 c->doUnchoke = 1; 1613 t->optimistic = c->peer; 1614 tr_ptrArrayFree( randPool, NULL ); 1586 1615 } 1587 1616 -
trunk/libtransmission/torrent-ctor.c
r4437 r4608 18 18 #include "utils.h" 19 19 20 #define DEFAULT_MAX_UNCHOKED_PEERS 1 620 #define DEFAULT_MAX_UNCHOKED_PEERS 12 21 21 #define DEFAULT_MAX_CONNECTED_PEERS 50 22 22
Note: See TracChangeset
for help on using the changeset viewer.