Changeset 2987


Ignore:
Timestamp:
Sep 8, 2007, 4:32:30 PM (14 years ago)
Author:
charles
Message:

downloading mostly works now. pulling down 250KiB/sec and using only 1% of my cpu...

Location:
branches/encryption
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/encryption/gtk/main.c

    r2554 r2987  
    168168
    169169static void
    170 safepipe(void);
    171 static void
    172170setupsighandlers(void);
    173171static void
     
    229227    gboolean     didinit, didlock, sendquit, startpaused;
    230228
    231     safepipe();                 /* ignore SIGPIPE */
    232229    argfiles = readargs( argc, argv, &sendquit, &startpaused );
    233230    didinit = cf_init( tr_getPrefsDirectory(), NULL );
     
    11081105
    11091106static void
    1110 safepipe(void) {
    1111   struct sigaction sa;
    1112 
    1113   memset(&sa, 0,  sizeof(sa));
    1114   sa.sa_handler = SIG_IGN;
    1115   sigaction(SIGPIPE, &sa, NULL);
    1116 }
    1117 
    1118 static void
    11191107setupsighandlers(void) {
    11201108  int sigs[] = {SIGHUP, SIGINT, SIGQUIT, SIGTERM};
  • branches/encryption/libtransmission/completion.c

    r2941 r2987  
    204204int tr_cpBlockIsComplete( const tr_completion * cp, int block )
    205205{
    206     return tr_bitfieldHas( cp->blockBitfield, block );
     206    return tr_bitfieldHas( cp->blockBitfield, block ) ? 1 : 0;
    207207}
    208208
  • branches/encryption/libtransmission/handshake.c

    r2985 r2987  
    672672    bytesRead += pstrlen;
    673673    assert( !strcmp( (char*)pstr, "BitTorrent protocol" ) );
     674    tr_free( pstr );
    674675
    675676    /* reserved bytes */
  • branches/encryption/libtransmission/list.c

    r2982 r2987  
    106106}
    107107
    108 void
    109 tr_list_remove_data ( tr_list ** list, const void * data )
     108static void*
     109tr_list_remove_node ( tr_list ** list, tr_list * node )
    110110{
    111     tr_list * node = tr_list_find_data( *list, data );
     111    void * data;
    112112    tr_list * prev = node ? node->prev : NULL;
    113113    tr_list * next = node ? node->next : NULL;
     
    115115    if( next ) next->prev = prev;
    116116    if( *list == node ) *list = next;
     117    data = node ? node->data : NULL;
    117118    node_free( node );
     119    return data;
    118120}
     121
     122void*
     123tr_list_remove_data ( tr_list ** list, const void * data )
     124{
     125    return tr_list_remove_node( list, tr_list_find_data( *list, data ) );
     126}
     127
     128void*
     129tr_list_remove( tr_list         ** list,
     130                const void       * b,
     131                TrListCompareFunc  compare_func )
     132{
     133    return tr_list_remove_node( list, tr_list_find( *list, b, compare_func ) );
     134}
     135
    119136
    120137tr_list*
     
    131148tr_list_foreach( tr_list * list, TrListForeachFunc func )
    132149{
    133     while( list )
    134     {
     150    while( list != NULL ) {
    135151        func( list->data );
    136152        list = list->next;
     
    141157tr_list_size( const tr_list * list )
    142158{
    143     int ret = 0;
    144 
    145     while( list )
    146     {
    147         ++list;
     159    int size = 0;
     160    while( list != NULL ) {
     161        ++size;
    148162        list = list->next;
    149163    }
    150 
    151     return ret;
     164    return size;
    152165}
  • branches/encryption/libtransmission/list.h

    r2982 r2987  
    3535                                     void             * data );
    3636
    37 void        tr_list_remove_data    ( tr_list         ** list,
     37void*       tr_list_remove_data    ( tr_list         ** list,
    3838                                     const void       * data );
     39
     40void*       tr_list_remove         ( tr_list         ** list,
     41                                     const void       * b,
     42                                     TrListCompareFunc  compare_func );
    3943
    4044void        tr_list_insert_sorted  ( tr_list         ** list,
  • branches/encryption/libtransmission/peer-io.c

    r2985 r2987  
    6464{
    6565    tr_peerIo * c = (tr_peerIo *) userData;
    66     assert( c->didWrite != NULL );
    67     (*c->didWrite)( e, c->userData );
     66    if( c->didWrite != NULL )
     67        (*c->didWrite)( e, c->userData );
    6868}
    6969
     
    7373    tr_peerIo * c = (tr_peerIo *) userData;
    7474
    75     assert( c->canRead != NULL );
     75    if( c->canRead == NULL )
     76        return;
    7677
    7778    for( ;; ) {
     
    7980        switch( ret ) {
    8081            case READ_AGAIN: if( EVBUFFER_LENGTH( e->input ) ) continue; /* note fall-through */
    81             case READ_MORE: fprintf( stderr, "waiting for bytes from peer...\n" );
     82            case READ_MORE: //fprintf( stderr, "waiting for bytes from peer...\n" );
    8283                            tr_peerIoSetIOMode( c, EV_READ, 0 ); return; break;
    8384            case READ_DONE: return; fprintf( stderr, "READ_DONE\n"); break;
  • branches/encryption/libtransmission/peer-mgr.c

    r2985 r2987  
    4040#define MAX_CONNECTED_PEERS 80
    4141
     42/**
     43***
     44**/
     45
    4246struct tr_block
    4347{
     48    unsigned int have          : 1;
     49    unsigned int dnd           : 1;
     50    unsigned int low_priority  : 1;
     51    unsigned int high_priority : 1;
     52    uint8_t requestCount;
     53    uint8_t scarcity;
    4454    uint32_t block;
    45     uint16_t scarcity;
    46     uint8_t priority;
    47     uint8_t requestCount;
    4855};
     56
     57#define MAX_SCARCITY UINT8_MAX
     58#define MAX_REQ_COUNT UINT8_MAX
     59
     60static void
     61incrementReqCount( struct tr_block * block )
     62{
     63    assert( block != NULL );
     64
     65    if( block->requestCount < MAX_REQ_COUNT )
     66        block->requestCount++;
     67}
     68
     69static void
     70incrementScarcity( struct tr_block * block )
     71{
     72    assert( block != NULL );
     73
     74    if( block->scarcity < MAX_SCARCITY )
     75        block->scarcity++;
     76}
     77
     78static int
     79compareBlockByIndex( const void * va, const void * vb )
     80{
     81    const struct tr_block * a = (const struct tr_block *) va;
     82    const struct tr_block * b = (const struct tr_block *) vb;
     83    return tr_compareUint32( a->block, b->block );
     84}
     85
     86static int
     87compareBlockByInterest( const void * va, const void * vb )
     88{
     89    const struct tr_block * a = (const struct tr_block *) va;
     90    const struct tr_block * b = (const struct tr_block *) vb;
     91    int i;
     92
     93    if( a->dnd != b->dnd )
     94        return a->dnd ? 1 : -1;
     95
     96    if( a->have != b->have )
     97        return a->have ? 1 : -1;
     98
     99    if(( i = tr_compareUint8( a->requestCount, b->requestCount )))
     100        return i;
     101
     102    if( a->high_priority != b->high_priority )
     103        return a->high_priority ? -1 : 1;
     104
     105    if( a->low_priority != b->low_priority )
     106        return a->low_priority ? 1 : -1;
     107
     108    if(( i = tr_compareUint16( a->scarcity, b->scarcity )))
     109        return i;
     110
     111    if(( i = tr_compareUint32( a->block, b->block )))
     112        return i;
     113
     114    return 0;
     115}
     116
     117/**
     118***
     119**/
    49120
    50121typedef struct
     
    53124    tr_ptrArray * peers; /* tr_peer */
    54125    tr_timer_tag choke_tag;
     126    tr_timer_tag refill_tag;
    55127    tr_torrent * tor;
    56128
    57129    struct tr_block * blocks;
    58130    uint32_t blockCount;
     131
     132    struct tr_peerMgr * manager;
    59133}
    60134Torrent;
     
    66140    int connectionCount;
    67141};
    68 
    69 /**
    70 ***
    71 **/
    72142
    73143/**
     
    163233    peers = (tr_peer **) tr_ptrArrayPeek( t->peers, &size );
    164234    tr_timerFree( &t->choke_tag );
     235    tr_timerFree( &t->refill_tag );
    165236    for( i=0; i<size; ++i )
    166237        freePeer( peers[i] );
     
    195266***
    196267**/
     268
     269static tr_peer**
     270getConnectedPeers( Torrent * t, int * setmeCount )
     271{
     272    int i, peerCount, connectionCount;
     273    tr_peer **peers = (tr_peer **) tr_ptrArrayPeek( t->peers, &peerCount );
     274    tr_peer **ret = tr_new( tr_peer*, peerCount );
     275
     276    for( i=connectionCount=0; i<peerCount; ++i )
     277        if( peers[i]->msgs != NULL )
     278            ret[connectionCount++] = peers[i];
     279
     280    *setmeCount = connectionCount;
     281    return ret;
     282}
     283
     284static int
     285refillPulse( void * vtorrent )
     286{
     287    uint32_t i;
     288    int size;
     289    Torrent * t = (Torrent *) vtorrent;
     290    tr_peer ** peers = getConnectedPeers( t, &size );
     291fprintf( stderr, "in refill pulse for [%s]... sorting blocks by interest...", t->tor->info.name );
     292
     293    /* sort the blocks by interest */
     294    qsort( t->blocks, t->blockCount, sizeof(struct tr_block), compareBlockByInterest );
     295fprintf( stderr, " .done.\n" );
     296
     297    /* walk through all the most interesting blocks */
     298    for( i=0; i<t->blockCount; ++i )
     299    {
     300        const uint32_t b = t->blocks[i].block;
     301        const uint32_t index = tr_torBlockPiece( t->tor, b );
     302        const uint32_t begin = ( b * t->tor->blockSize )-( index * t->tor->info.pieceSize );
     303        const uint32_t length = tr_torBlockCountBytes( t->tor, (int)b );
     304        int j;
     305
     306        if( t->blocks[i].have || t->blocks[i].dnd )
     307            continue;
     308        if( !size ) { /* all peers full */
     309            fprintf( stderr, "all peers full...\n" );
     310            break;
     311        }
     312
     313        /* find a peer who can ask for this block */
     314        for( j=0; j<size; )
     315        {
     316            const int val = tr_peerMsgsAddRequest( peers[j]->msgs, index, begin, length );
     317//fprintf( stderr, " block %"PRIu64", peer %"PRIu64, (uint64_t)i,  (uint64_t)j );
     318            if( val == TR_ADDREQ_FULL ) {
     319fprintf( stderr, "peer %d of %d is full\n", (int)j, size );
     320                peers[j] = peers[--size];
     321            }
     322            else if( val == TR_ADDREQ_MISSING ) {
     323//fprintf( stderr, "peer doesn't have it\n" );
     324                ++j;
     325            }
     326            else if( val == TR_ADDREQ_OK ) {
     327fprintf( stderr, "peer %d took the request for block %d\n", j, i );
     328                incrementReqCount( &t->blocks[i] );
     329                j = size;
     330            }
     331        }
     332    }
     333
     334    /* put the blocks back by index */
     335    qsort( t->blocks, t->blockCount, sizeof(struct tr_block), compareBlockByIndex );
     336
     337    /* cleanup */
     338    tr_free( peers );
     339
     340    /* let the timer expire */
     341    t->refill_tag = NULL;
     342    return FALSE;
     343}
     344
     345static void
     346ensureRefillTag( Torrent * t )
     347{
     348    if( t->refill_tag == NULL )
     349        t->refill_tag = tr_timerNew( t->manager->handle,
     350                                     refillPulse, t, NULL, 5000 );
     351}
    197352
    198353static void
     
    212367                    continue;
    213368                assert( t->blocks[i].block == i );
    214                 if( t->blocks[i].scarcity < UINT8_MAX )
    215                     t->blocks[i].scarcity++;
     369                incrementScarcity( &t->blocks[i] );
    216370            }
    217371            break;
     
    224378            for( i=begin; i<end; ++i ) {
    225379                assert( t->blocks[i].block == i );
    226                 if( t->blocks[i].scarcity < UINT8_MAX )
    227                     t->blocks[i].scarcity++;
     380                incrementScarcity( &t->blocks[i] );
    228381            }
    229382            break;
    230383        }
    231384
     385        case TR_PEERMSG_GOT_BLOCK: {
     386            uint32_t i = e->blockIndex;
     387            assert( t->blocks[i].block == i );
     388            t->blocks[i].have = 1;
     389            break;
     390        }
     391
    232392        case TR_PEERMSG_GOT_PEX:
    233393            /* FIXME */
     
    239399
    240400        case TR_PEERMSG_BLOCKS_RUNNING_LOW:
    241             /* FIXME */
     401            ensureRefillTag( t );
    242402            break;
    243403
     
    301461        tr_peer * peer = getPeer( t, in_addr );
    302462        peer->port = port;
     463        peer->io = io;
    303464        peer->msgs = tr_peerMsgsNew( t->tor, peer );
    304465        peer->msgsTag = tr_peerMsgsSubscribe( peer->msgs, msgsCallbackFunc, t );
     
    468629
    469630    t = tr_new0( Torrent, 1 );
     631    t->manager = manager;
    470632    t->tor = tor;
    471633    t->peers = tr_ptrArrayNew( );
     
    473635                                chokePulse, t, NULL,
    474636                                RECHOKE_PERIOD_SECONDS );
     637
    475638    t->blockCount = tor->blockCount;
    476     t->blocks = tr_new0( struct tr_block, t->blockCount );
     639    t->blocks = tr_new( struct tr_block, t->blockCount );
    477640    for( i=0; i<t->blockCount; ++i ) {
     641        const int index = tr_torBlockPiece( tor, i );
     642        t->blocks[i].have = tr_cpBlockIsComplete( t->tor->completion, i ) ? 1 : 0;
     643if( tr_cpBlockIsComplete( t->tor->completion, i ) ) fprintf( stderr, "have block %d\n", (int)i );
     644        t->blocks[i].dnd = tor->info.pieces[index].dnd;
     645        t->blocks[i].low_priority = tor->info.pieces[index].priority == TR_PRI_LOW;
     646        t->blocks[i].high_priority = tor->info.pieces[index].priority == TR_PRI_HIGH;
     647        t->blocks[i].requestCount = 0;
     648        t->blocks[i].scarcity = 0;
    478649        t->blocks[i].block = i;
    479         t->blocks[i].scarcity = tr_cpBlockIsComplete( t->tor->completion, i )
    480                                                       ? UINT32_MAX : 0;
    481     }
     650    }
     651
    482652    memcpy( t->hash, tor->info.hash, SHA_DIGEST_LENGTH );
    483653    tr_ptrArrayInsertSorted( manager->torrents, t, torrentCompare );
     
    659829    int i, size, unchoked;
    660830    const int done = tr_cpGetStatus( t->tor->completion ) != TR_CP_INCOMPLETE;
    661     tr_peer ** peers = (tr_peer **) tr_ptrArrayPeek( t->peers, &size );
    662831    float bestDownloaderRate;
    663832    ChokeData * data;
     833    tr_peer ** peers = getConnectedPeers( t, &size );
    664834
    665835fprintf( stderr, "rechoking torrent %p, with %d peers\n", t, size );
     
    680850    bestDownloaderRate = data[0].rate;
    681851    for( i=unchoked=0; i<size && unchoked<NUM_DOWNLOADERS_TO_UNCHOKE; ++i ) {
    682         if( data[i].peer->msgs != NULL ) {
    683             tr_peerMsgsSetChoke( data[i].peer->msgs, FALSE );
    684             ++unchoked;
    685         }
     852        tr_peerMsgsSetChoke( data[i].peer->msgs, FALSE );
     853        ++unchoked;
    686854    }
    687855    memmove( data, data+i, sizeof(ChokeData)*(size-i) );
     
    704872    /* cleanup */
    705873    tr_free( data );
     874    tr_free( peers );
    706875    return TRUE;
    707876}
  • branches/encryption/libtransmission/peer-msgs.c

    r2985 r2987  
    4545
    4646/* the most requests we'll batch up for this peer */
    47 #define OUT_REQUESTS_MAX 10
     47#define OUT_REQUESTS_MAX 6
    4848
    4949/* when we get down to this many requests, we ask the manager for more */
    50 #define OUT_REQUESTS_LOW 4
     50#define OUT_REQUESTS_LOW 2
    5151
    5252enum
     
    146146**/
    147147
    148 static const tr_peermsgs_event blankEvent = { 0, 0, NULL };
     148static const tr_peermsgs_event blankEvent = { 0, 0, 0, NULL };
    149149
    150150static void
     
    177177    e.eventType = TR_PEERMSG_GOT_HAVE;
    178178    e.pieceIndex = pieceIndex;
     179    tr_publisherPublish( peer->publisher, peer, &e );
     180}
     181
     182static void
     183fireGotBlock( tr_peermsgs * peer, uint32_t blockIndex )
     184{
     185    tr_peermsgs_event e = blankEvent;
     186    e.eventType = TR_PEERMSG_GOT_BLOCK;
     187    e.pieceIndex = blockIndex;
    179188    tr_publisherPublish( peer->publisher, peer, &e );
    180189}
     
    254263{
    255264    assert( peer != NULL );
     265    assert( peer->info != NULL );
    256266
    257267    if( peer->info->peerIsChoked != !!choke )
     
    283293                       uint32_t      length )
    284294{
    285     int ret =-1;
    286 
    287     if( tr_list_size(peer->clientAskedFor) < OUT_REQUESTS_MAX )
    288     {
    289         const uint8_t bt_msgid = BT_REQUEST;
    290         const uint32_t len = sizeof(uint8_t) + 3 * sizeof(uint32_t);
    291         struct peer_request * req = tr_new( struct peer_request, 1 );
    292 
    293         tr_peerIoWriteUint32( peer->io, peer->outMessages, len );
    294         tr_peerIoWriteBytes( peer->io, peer->outMessages, &bt_msgid, 1 );
    295         tr_peerIoWriteUint32( peer->io, peer->outMessages, index );
    296         tr_peerIoWriteUint32( peer->io, peer->outMessages, offset );
    297         tr_peerIoWriteUint32( peer->io, peer->outMessages, length );
    298         fprintf( stderr, "peer %p: requesting a block from piece %u, offset %u, length %u\n",
    299                          peer, (unsigned int)index, (unsigned int)offset, (unsigned int)length );
    300 
    301         req->index = index;
    302         req->offset = offset;
    303         req->length = length;
    304         tr_list_append( &peer->clientAskedFor, req );
    305 
    306         ret = 0;
    307     }
    308 
    309     return ret;
     295    const uint8_t bt_msgid = BT_REQUEST;
     296    const uint32_t len = sizeof(uint8_t) + 3 * sizeof(uint32_t);
     297    struct peer_request * req;
     298
     299    if( tr_list_size(peer->clientAskedFor) >= OUT_REQUESTS_MAX )
     300        return TR_ADDREQ_FULL;
     301
     302    if( !tr_bitfieldHas( peer->info->have, index ) )
     303        return TR_ADDREQ_MISSING;
     304
     305    /* queue the request */
     306    tr_peerIoWriteUint32( peer->io, peer->outMessages, len );
     307    tr_peerIoWriteBytes( peer->io, peer->outMessages, &bt_msgid, 1 );
     308    tr_peerIoWriteUint32( peer->io, peer->outMessages, index );
     309    tr_peerIoWriteUint32( peer->io, peer->outMessages, offset );
     310    tr_peerIoWriteUint32( peer->io, peer->outMessages, length );
     311    fprintf( stderr, "peer %p: requesting a block from piece %u, offset %u, length %u\n",
     312             peer, (unsigned int)index, (unsigned int)offset, (unsigned int)length );
     313
     314    /* add it to our `requests sent' list */
     315    req = tr_new( struct peer_request, 1 );
     316    req->index = index;
     317    req->offset = offset;
     318    req->length = length;
     319    tr_list_prepend( &peer->clientAskedFor, req );
     320    fprintf( stderr, "added a request; peer %p's clientAskedFor.size() is now %d\n", peer, tr_list_size(peer->clientAskedFor));
     321
     322    return TR_ADDREQ_OK;
    310323}
    311324
     
    436449        peer->gotKeepAliveTime = tr_date( );
    437450    } else {
    438         fprintf( stderr, "peer is sending us a message with %d bytes...\n", (int)len );
     451        fprintf( stderr, "peer is sending us a message with %"PRIu64" bytes...\n", (uint64_t)len );
    439452        peer->incomingMessageLength = len;
     453        fprintf( stderr, "peer is sending us a message with %"PRIu64" bytes...\n", (uint64_t)peer->incomingMessageLength );
    440454        peer->state = AWAITING_BT_MESSAGE;
    441455    } return READ_AGAIN;
     
    447461    uint8_t id;
    448462    uint32_t ui32;
    449     size_t msglen = peer->incomingMessageLength;
     463    uint32_t msglen = peer->incomingMessageLength;
    450464
    451465    if( EVBUFFER_LENGTH(inbuf) < msglen )
     
    521535            tr_peerIoReadUint32( peer->io, inbuf, &req->length );
    522536            if( !peer->info->peerIsChoked )
    523                 tr_list_append( &peer->peerAskedFor, req );
     537                tr_list_prepend( &peer->peerAskedFor, req );
    524538            break;
    525539        }
     
    548562            tr_peerIoReadUint32( peer->io, inbuf, &peer->blockToUs.offset );
    549563            peer->blockToUs.length = msglen - 8;
     564fprintf( stderr, "left to read is [%"PRIu64"]\n", (uint64_t)peer->blockToUs.length );
    550565            assert( peer->blockToUs.length > 0 );
    551566            evbuffer_drain( peer->inBlock, ~0 );
     567            return READ_AGAIN;
    552568            break;
    553569        }
     
    606622    /* sanity clause */
    607623    if( tr_cpBlockIsComplete( tor->completion, block ) ) {
     624fprintf( stderr, "have this block already...\n" );
    608625        tr_dbg( "have this block already..." );
    609626        return;
    610627    }
    611628    if( (int)length != tr_torBlockCountBytes( tor, block ) ) {
     629fprintf( stderr, "block is the wrong length... expected %d and got %d\n", (int)length, (int)tr_torBlockCountBytes(tor,block) );
    612630        tr_dbg( "block is the wrong length..." );
    613631        return;
     
    618636    key.offset = offset;
    619637    key.length = length;
    620     req = (struct peer_request*) tr_list_find( peer->clientAskedFor, &key,
    621                                                peer_request_compare );
     638    req = (struct peer_request*) tr_list_remove( &peer->clientAskedFor, &key,
     639                                                 peer_request_compare );
    622640    if( req == NULL ) {
     641fprintf( stderr, "we didn't ask for this message...\n" );
    623642        tr_dbg( "we didn't ask the peer for this message..." );
    624643        return;
    625644    }
    626     tr_list_remove_data( &peer->clientAskedFor, req );
    627645    tr_free( req );
     646    fprintf( stderr, "peer %p now has %d block requests in its outbox\n", peer, tr_list_size(peer->clientAskedFor));
     647
     648    {
     649        uint64_t block = index;
     650        block *= tor->info.pieceSize;
     651        block += offset;
     652        block /= tor->blockSize;
     653        fireGotBlock( peer, (uint32_t)block );
     654    }
    628655
    629656    /* write to disk */
     
    641668    tr_rcTransferred( tor->download, length );
    642669    tr_rcTransferred( tor->handle->download, length );
    643 
    644     if( tr_list_size(peer->clientAskedFor) <= OUT_REQUESTS_LOW )
    645         fireBlocksRunningLow( peer );
    646670}
    647671
     
    667691        tr_free( tmp );
    668692        peer->blockToUs.length -= len;
     693fprintf( stderr, "got %"PRIu64"; left to read is [%"PRIu64"]\n", (uint64_t)len, (uint64_t)peer->blockToUs.length );
     694
    669695
    670696        if( !peer->blockToUs.length )
    671697        {
     698fprintf( stderr, "w00t\n" );
    672699            gotBlock( peer, peer->blockToUs.index,
    673700                            peer->blockToUs.offset,
     
    737764        {
    738765            const size_t outlen = MIN( len, 4096 );
    739 fprintf( stderr, "peer %p outblock writing %d bytes...\n", peer, (int)outlen );
    740766            tr_peerIoWrite( peer->io, EVBUFFER_DATA(peer->outBlock), outlen );
    741767            evbuffer_drain( peer->outBlock, outlen );
     
    767793        tr_free( tmp );
    768794    }
     795
     796    if( tr_list_size(peer->clientAskedFor) <= OUT_REQUESTS_LOW )
     797        fireBlocksRunningLow( peer );
    769798
    770799    return TRUE; /* loop forever */
  • branches/encryption/libtransmission/peer-msgs.h

    r2984 r2987  
    3030void         tr_peerMsgsFree( tr_peermsgs* );
    3131
     32
     33enum { TR_ADDREQ_OK=0, TR_ADDREQ_FULL, TR_ADDREQ_MISSING };
     34
    3235int          tr_peerMsgsAddRequest( tr_peermsgs * peer,
    3336                                    uint32_t      index,
     
    4346    TR_PEERMSG_GOT_BITFIELD,
    4447    TR_PEERMSG_GOT_HAVE,
     48    TR_PEERMSG_GOT_BLOCK,
    4549    TR_PEERMSG_GOT_PEX,
    4650    TR_PEERMSG_GOT_ERROR,
     
    5357    PeerMsgsEventType eventType;
    5458    uint32_t pieceIndex; /* for TR_PEERMSG_GOT_HAVE */
     59    uint32_t blockIndex; /* For TR_PEERMSG_GOT_BLOCK */
    5560    const struct tr_bitfield * bitfield; /* for TR_PEERMSG_GOT_BITFIELD */
    5661}
  • branches/encryption/libtransmission/utils.c

    r2978 r2987  
    296296#endif
    297297
     298/**
     299***
     300**/
     301
     302int
     303tr_compareUint8 (  uint8_t a,  uint8_t b )
     304{
     305    if( a < b ) return -1;
     306    if( a > b ) return 1;
     307    return 0;
     308}
     309
     310int
     311tr_compareUint16( uint16_t a, uint16_t b )
     312{
     313    if( a < b ) return -1;
     314    if( a > b ) return 1;
     315    return 0;
     316}
     317
     318int
     319tr_compareUint32( uint32_t a, uint32_t b )
     320{
     321    if( a < b ) return -1;
     322    if( a > b ) return 1;
     323    return 0;
     324}
     325
     326int
     327tr_compareUint64( uint64_t a, uint64_t b )
     328{
     329    if( a < b ) return -1;
     330    if( a > b ) return 1;
     331    return 0;
     332}
     333
     334/**
     335***
     336**/
     337
    298338struct timeval
    299339timevalSec ( int seconds )
  • branches/encryption/libtransmission/utils.h

    r2978 r2987  
    150150                     void * userData );
    151151                   
     152int tr_compareUint8 (  uint8_t a,  uint8_t b );
     153int tr_compareUint16( uint16_t a, uint16_t b );
     154int tr_compareUint32( uint32_t a, uint32_t b );
     155int tr_compareUint64( uint64_t a, uint64_t b );
    152156
    153157/***
Note: See TracChangeset for help on using the changeset viewer.