Changeset 3197


Ignore:
Timestamp:
Sep 27, 2007, 3:03:38 AM (14 years ago)
Author:
charles
Message:

some experimental code. (1) try to improve throughput to peers. (2) add first draft of new tr_stat fields requested by BentMyWookie? (3) raise the per-torrent peer limit to 100 to match LibTorrent?'s defaults

Location:
trunk/libtransmission
Files:
5 edited

Legend:

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

    r3184 r3197  
    6969    /* this is arbitrary and, hopefully, temporary until we come up
    7070     * with a better idea for managing the connection limits */
    71     MAX_CONNECTED_PEERS_PER_TORRENT = 60,
     71    MAX_CONNECTED_PEERS_PER_TORRENT = 100,
    7272
    7373    /* if we hang up on a peer for being worthless, don't try to
     
    651651
    652652        case TR_PEERMSG_PEER_PROGRESS: { /* if we're both seeds, then disconnect. */
     653#if 0
    653654            const int clientIsSeed = tr_cpGetStatus( t->tor->completion ) != TR_CP_INCOMPLETE;
    654655            const int peerIsSeed = e->progress >= 1.0;
    655656            if( clientIsSeed && peerIsSeed )
    656657                peer->doPurge = 1;
     658#endif
    657659            break;
    658660        }
     
    967969}
    968970
     971/* Returns the pieces that we and/or a connected peer has */
     972tr_bitfield*
     973tr_peerMgrGetAvailable( const tr_peerMgr * manager,
     974                        const uint8_t    * torrentHash )
     975{
     976    int i, size;
     977    const Torrent * t;
     978    const tr_peer ** peers;
     979    tr_bitfield * pieces;
     980
     981    t = getExistingTorrent( (tr_peerMgr*)manager, torrentHash );
     982    peers = (const tr_peer **) tr_ptrArrayPeek( t->peers, &size );
     983    pieces = tr_bitfieldDup( tr_cpPieceBitfield( t->tor->completion ) );
     984    for( i=0; i<size; ++i )
     985        if( peers[i]->io != NULL )
     986            tr_bitfieldAnd( pieces, peers[i]->have );
     987
     988    return pieces;
     989}
    969990
    970991void
  • trunk/libtransmission/peer-mgr.h

    r3171 r3197  
    8282                                    int                tabCount );
    8383
     84struct tr_bitfield* tr_peerMgrGetAvailable( const tr_peerMgr * manager,
     85                                            const uint8_t    * torrentHash );
     86
    8487void tr_peerMgrTorrentStats( const tr_peerMgr * manager,
    8588                             const uint8_t    * torrentHash,
  • trunk/libtransmission/peer-msgs.c

    r3188 r3197  
    608608        dbgmsg( msgs, "peer sent us a keepalive message..." );
    609609    else {
    610         dbgmsg( msgs, "peer is sending us a message with %"PRIu64" bytes...\n", (uint64_t)len );
     610        dbgmsg( msgs, "peer is sending us a message with %"PRIu64" bytes...", (uint64_t)len );
    611611        msgs->incomingMessageLength = len;
    612612        msgs->state = AWAITING_BT_MESSAGE;
     
    10051005{
    10061006    /* don't let our outbuffer get too large */
    1007     if( tr_peerIoWriteBytesWaiting( msgs->io ) > 2048 )
     1007    if( tr_peerIoWriteBytesWaiting( msgs->io ) > 8192 )
    10081008        return FALSE;
    10091009
     
    10511051        while ( len && canUpload( msgs ) )
    10521052        {
    1053             const size_t outlen = MIN( len, 2048 );
     1053            const size_t outlen = len; //MIN( len, 2048 );
    10541054            tr_peerIoWrite( msgs->io, EVBUFFER_DATA(msgs->outBlock), outlen );
    10551055            evbuffer_drain( msgs->outBlock, outlen );
  • trunk/libtransmission/torrent.c

    r3178 r3197  
    809809    s->haveValid       = tr_cpHaveValid( tor->completion );
    810810    s->haveUnchecked   = tr_cpHaveTotal( tor->completion ) - s->haveValid;
     811
     812
     813    {
     814        int i;
     815        tr_bitfield * available = tr_peerMgrGetAvailable( tor->handle->peerMgr,
     816                                                          tor->info.hash );
     817        s->nonDndSize = 0;
     818        s->nonDndAvailable = 0;
     819
     820        for( i=0; i<tor->info.pieceCount; ++i ) {
     821            if( !tor->info.pieces[i].dnd ) {
     822                s->nonDndSize += tor->info.pieceSize;
     823                if( tr_bitfieldHas( available, i ) )
     824                    s->nonDndAvailable += tor->info.pieceSize;
     825            }
     826        }
     827
     828        tr_bitfieldFree( available );
     829    }
    811830   
    812831    s->ratio = s->downloadedEver ? s->uploadedEver / (float)s->downloadedEver
  • trunk/libtransmission/transmission.h

    r3178 r3197  
    673673    uint64_t            haveUnchecked;
    674674
     675    /* Byte count of all the non-DND piece data that either we already have,
     676     * or that a peer we're connected to has. [0...tr_info.totalSize] */
     677    uint64_t            nonDndAvailable;
     678
     679    /* Byte count of all the non-DND piece data */
     680    uint64_t            nonDndSize;
     681
    675682    float               swarmspeed;
    676683
Note: See TracChangeset for help on using the changeset viewer.