Changeset 3349


Ignore:
Timestamp:
Oct 10, 2007, 4:39:12 PM (14 years ago)
Author:
charles
Message:

commit more of tiennou's fastpeers patch

Location:
trunk/libtransmission
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/crypto.c

    r3105 r3349  
    109109    DH_generate_key( crypto->dh );
    110110
    111     // DH can generate key sizes that are smaller than the size of
    112     // P with exponentially decreasing probability, in which case
    113     // the msb's of myPublicKey need to be zeroed appropriately.
     111    /* DH can generate key sizes that are smaller than the size of
     112      P with exponentially decreasing probability, in which case
     113       the msb's of myPublicKey need to be zeroed appropriately. */
    114114    len = DH_size( crypto->dh );
    115115    offset = KEY_LEN - len;
  • trunk/libtransmission/peer-mgr.c

    r3348 r3349  
    548548    const struct tr_refill_piece * a = aIn;
    549549    const struct tr_refill_piece * b = bIn;
    550 
     550   
     551    /* if one *might be* fastallowed to us, get it first...
     552     * I'm putting it on top so we prioritise those pieces at
     553     * startup, then we'll have them, and we'll be denied access
     554     * to them */
     555    if (a->fastAllowed != b->fastAllowed)
     556        return a->fastAllowed < b->fastAllowed ? -1 : 1;
     557   
    551558    /* if one piece has a higher priority, it goes first */
    552559    if (a->priority != b->priority)
    553560        return a->priority > b->priority ? -1 : 1;
    554 
     561   
    555562    /* otherwise if one has fewer peers, it goes first */
    556563    if (a->peerCount != b->peerCount)
    557564        return a->peerCount < b->peerCount ? -1 : 1;
    558    
    559     /* otherwise if one *might be* fastallowed to us */
    560     if (a->fastAllowed != b->fastAllowed)
    561         return a->fastAllowed < b->fastAllowed ? -1 : 1;
    562565
    563566    /* otherwise go with our random seed */
     
    615618            setme->fastAllowed = 0;
    616619            setme->random = tr_rand( UINT16_MAX );
    617             /* FIXME */
    618 //            setme->fastAllowed = tr_bitfieldHas( t->tor->allowedList, i);
    619620
    620621            for( k=0; k<peerCount; ++k ) {
     
    622623                if( peer->peerIsInterested && !peer->clientIsChoked && tr_bitfieldHas( peer->have, piece ) )
    623624                    ++setme->peerCount;
     625                /* The fast peer extension doesn't force a peer to actually HAVE a fast-allowed piece,
     626                    but we're guaranteed to get the same pieces from different peers,
     627                    so we'll build a list and pray one actually have this one */
     628                setme->fastAllowed = tr_peerMsgIsPieceFastAllowed( peer->msgs, i);
    624629            }
    625630        }
     
    16121617        nAdd = MAX_CONNECTED_PEERS_PER_TORRENT - peerCount;
    16131618        for( i=0; i<nAdd && i<nCandidates && i<MAX_RECONNECTIONS_PER_PULSE; ++i )
    1614         //for( i=0; i<nCandidates; ++i )
    16151619        {
    16161620            tr_peerMgr * mgr = t->manager;
  • trunk/libtransmission/peer-msgs.c

    r3347 r3349  
    10241024            msgs->blockToUs.length = msglen - 8;
    10251025            assert( EVBUFFER_LENGTH(msgs->inBlock) == 0 );
    1026             //evbuffer_drain( msgs->inBlock, ~0 );
    10271026            msgs->state = msgs->blockToUs.length ? READING_BT_PIECE : AWAITING_BT_LENGTH;
    10281027            return READ_AGAIN;
     
    17241723    tr_publisherUnsubscribe( peer->publisher, tag );
    17251724}
     1725
     1726int
     1727tr_peerMsgIsPieceFastAllowed( const tr_peermsgs * peer,
     1728                              uint32_t            index )
     1729{
     1730    return tr_bitfieldHas( peer->clientAllowedPieces, index );
     1731}
     1732
  • trunk/libtransmission/peer-msgs.h

    r3295 r3349  
    8888                                           tr_publisher_tag    tag );
    8989
    90 
     90int               tr_peerMsgIsPieceFastAllowed( const tr_peermsgs * peer,
     91                                                uint32_t            index );
    9192
    9293#endif
  • trunk/libtransmission/transmission.c

    r3295 r3349  
    313313tr_close( tr_handle * h )
    314314{
    315     //assert( tr_torrentCount( h ) == 0 );
    316 
    317315    tr_runInEventThread( h, tr_closeImpl, h );
    318316    while( !h->isClosed )
     
    357355                if( tor != NULL ) {
    358356                    tr_list_append( &list, tor );
    359                     //fprintf (stderr, "#%d - %s\n", n, tor->info.name );
    360357                    n++;
    361358                }
  • trunk/libtransmission/trevent.c

    r3319 r3349  
    205205
    206206    eh->base = event_init( );
    207     //event_set_log_callback( logFunc );
    208207    evdns_init( );
    209208    timeout_set( &eh->pulse, pumpList, veh );
     
    243242    eh->die = TRUE;
    244243    tr_lockUnlock( eh->lock );
    245 
    246     //event_base_loopexit( eh->base, NULL );
    247244}
    248245
Note: See TracChangeset for help on using the changeset viewer.