Changeset 7545


Ignore:
Timestamp:
Dec 30, 2008, 8:20:16 AM (12 years ago)
Author:
charles
Message:

(trunk libT) remove obsolete tr_peerMgr.c's getConnectedPeers()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r7524 r7545  
    496496}
    497497
    498 static tr_peer**
    499 getConnectedPeers( Torrent * t, int * setmeCount )
    500 {
    501     int i, peerCount, connectionCount;
    502     tr_peer **peers;
    503     tr_peer **ret;
    504 
    505     assert( torrentIsLocked( t ) );
    506 
    507     peers = (tr_peer **) tr_ptrArrayPeek( &t->peers, &peerCount );
    508     ret = tr_new( tr_peer *, peerCount );
    509 
    510     for( i = connectionCount = 0; i < peerCount; ++i )
    511         if( peers[i]->msgs )
    512             ret[connectionCount++] = peers[i];
    513 
    514     *setmeCount = connectionCount;
    515     return ret;
    516 }
    517 
    518498static int
    519499clientIsDownloadingFrom( const tr_peer * peer )
     
    639619    tr_piece_index_t  * pool = tr_new( tr_piece_index_t , inf->pieceCount );
    640620    int                 peerCount;
    641     tr_peer**          peers;
     621    const tr_peer    ** peers;
    642622
    643623    assert( torrentIsLocked( t ) );
    644624
    645     peers = getConnectedPeers( t, &peerCount );
     625    peers = (const tr_peer**) TR_PTR_ARRAY_DATA( &t->peers );
     626    peerCount = TR_PTR_ARRAY_LENGTH( &t->peers );
    646627
    647628    /* make a list of the pieces that we want but don't have */
     
    689670        tr_free( p );
    690671    }
    691 
    692     tr_free( peers );
    693672
    694673    *pieceCount = poolSize;
     
    888867broadcastGotBlock( Torrent * t, uint32_t index, uint32_t offset, uint32_t length )
    889868{
    890     int i, size;
     869    size_t i;
     870    size_t peerCount;
    891871    tr_peer ** peers;
    892872
     
    894874
    895875    tordbg( t, "got a block; cancelling any duplicate requests from peers %"PRIu32":%"PRIu32"->%"PRIu32, index, offset, length );
    896     peers = getConnectedPeers( t, &size );
    897     for( i=0; i<size; ++i )
    898         tr_peerMsgsCancel( peers[i]->msgs, index, offset, length );
    899     tr_free( peers );
     876
     877    peerCount = TR_PTR_ARRAY_LENGTH( &t->peers );
     878    peers = (tr_peer**) TR_PTR_ARRAY_DATA( &t->peers );
     879    for( i=0; i<peerCount; ++i )
     880        if( peers[i]->msgs )
     881            tr_peerMsgsCancel( peers[i]->msgs, index, offset, length );
    900882}
    901883
     
    11221104                else
    11231105                {
    1124                     int i, peerCount;
    1125                     tr_peer ** peers = getConnectedPeers( t, &peerCount );
    1126                     for( i = 0; i < peerCount; ++i )
     1106                    int i;
     1107                    int peerCount = TR_PTR_ARRAY_LENGTH( &t->peers );
     1108                    tr_peer ** peers = (tr_peer**) TR_PTR_ARRAY_DATA( &t->peers );
     1109                    for( i=0; i<peerCount; ++i )
    11271110                        tr_peerMsgsHave( peers[i]->msgs, p );
    1128                     tr_free( peers );
    11291111                }
    11301112
     
    16751657    int                peerCount;
    16761658    const tr_peer **   peers;
    1677 
    16781659    managerLock( manager );
    16791660
     
    17091690                        const uint8_t *    torrentHash )
    17101691{
    1711     int           i, size;
    1712     Torrent *     t;
    1713     tr_peer **    peers;
     1692    int i;
     1693    int peerCount;
     1694    Torrent * t;
     1695    const tr_peer ** peers;
    17141696    tr_bitfield * pieces;
    17151697    managerLock( manager );
     
    17171699    t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
    17181700    pieces = tr_bitfieldNew( t->tor->info.pieceCount );
    1719     peers = getConnectedPeers( t, &size );
    1720     for( i = 0; i < size; ++i )
     1701    peerCount = TR_PTR_ARRAY_LENGTH( &t->peers );
     1702    peers = (const tr_peer**) TR_PTR_ARRAY_DATA( &t->peers );
     1703    for( i=0; i<peerCount; ++i )
    17211704        tr_bitfieldOr( pieces, peers[i]->have );
    17221705
    17231706    managerUnlock( manager );
    1724     tr_free( peers );
    17251707    return pieces;
    17261708}
     
    18461828                     int                 * setmeCount UNUSED )
    18471829{
    1848     int             i, size;
     1830    int i, size;
    18491831    const Torrent * t;
    1850     tr_peer **      peers;
    1851     tr_peer_stat *  ret;
     1832    const tr_peer ** peers;
     1833    tr_peer_stat * ret;
    18521834
    18531835    assert( manager );
     
    18551837
    18561838    t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
    1857     peers = getConnectedPeers( (Torrent*)t, &size );
     1839    size = TR_PTR_ARRAY_LENGTH( &t->peers );
     1840    peers = (const tr_peer**) TR_PTR_ARRAY_DATA( &t->peers );
    18581841    ret = tr_new0( tr_peer_stat, size );
    18591842
     
    19011884
    19021885    *setmeCount = size;
    1903     tr_free( peers );
    19041886
    19051887    managerUnlock( manager );
     
    19551937rechoke( Torrent * t )
    19561938{
    1957     int                i, peerCount, size, unchokedInterested;
    1958     tr_peer **         peers = getConnectedPeers( t, &peerCount );
     1939    int i, size, unchokedInterested;
     1940    const int peerCount = TR_PTR_ARRAY_LENGTH( &t->peers );
     1941    tr_peer ** peers = (tr_peer**) TR_PTR_ARRAY_DATA( &t->peers );
    19591942    struct ChokeData * choke = tr_new0( struct ChokeData, peerCount );
    1960     const int          chokeAll = !tr_torrentIsPieceTransferAllowed( t->tor, TR_CLIENT_TO_PEER );
     1943    const int chokeAll = !tr_torrentIsPieceTransferAllowed( t->tor, TR_CLIENT_TO_PEER );
    19611944
    19621945    assert( torrentIsLocked( t ) );
     
    20472030    /* cleanup */
    20482031    tr_free( choke );
    2049     tr_free( peers );
    20502032}
    20512033
Note: See TracChangeset for help on using the changeset viewer.