Changeset 2949


Ignore:
Timestamp:
Aug 30, 2007, 8:51:35 PM (15 years ago)
Author:
charles
Message:

add libevent-ized uploads, downloads, speed limits, choke messages. It's still at least a weekend away from being something even bleeding-edge testers would want to try.

Location:
branches/encryption/libtransmission
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/encryption/libtransmission/inout.c

    r2941 r2949  
    141141static int
    142142readOrWritePiece ( tr_torrent       * tor,
    143                    int                  ioMode,
    144                    int                  pieceIndex,
    145                    int                  pieceOffset,
    146                    uint8_t            * buf,
    147                    size_t               buflen )
     143                   int                ioMode,
     144                   int                pieceIndex,
     145                   int                pieceOffset,
     146                   uint8_t          * buf,
     147                   size_t             buflen )
    148148{
    149149    int ret = 0;
     
    178178
    179179int
    180 tr_ioRead( tr_io_t * io, int pieceIndex, int begin, int len, uint8_t * buf )
    181 {
    182     return readOrWritePiece ( io->tor, TR_IO_READ, pieceIndex, begin, buf, len );
     180tr_ioRead( tr_torrent * tor, int pieceIndex, int begin, int len, uint8_t * buf )
     181{
     182    return readOrWritePiece ( tor, TR_IO_READ, pieceIndex, begin, buf, len );
    183183}
    184184
    185185int
    186 tr_ioWrite( tr_io_t * io, int pieceIndex, int begin, int len, uint8_t * buf )
    187 {
    188     return readOrWritePiece ( io->tor, TR_IO_WRITE, pieceIndex, begin, buf, len );
     186tr_ioWrite( tr_torrent * tor, int pieceIndex, int begin, int len, uint8_t * buf )
     187{
     188    return readOrWritePiece ( tor, TR_IO_WRITE, pieceIndex, begin, buf, len );
    189189}
    190190
  • branches/encryption/libtransmission/inout.h

    r2941 r2949  
    2626#define TR_IO_H 1
    2727
     28struct tr_torrent;
     29
    2830typedef struct tr_io_s tr_io_t;
    2931
     
    4042 * TR_ERROR_IO_* otherwise.
    4143 **********************************************************************/
    42 int tr_ioRead  ( tr_io_t *, int index, int begin, int len, uint8_t * );
    43 int tr_ioWrite ( tr_io_t *, int index, int begin, int len, uint8_t * );
     44int tr_ioRead  ( struct tr_torrent*, int index, int begin, int len, uint8_t * );
     45int tr_ioWrite ( struct tr_torrent *, int index, int begin, int len, uint8_t * );
    4446
    4547/***********************************************************************
  • branches/encryption/libtransmission/p.c

    r2946 r2949  
    88 * the Transmission project.
    99 *
    10  * $Id:$
     10 * $Id$
    1111 */
    1212
     
    2525#include "bencode.h"
    2626#include "completion.h"
     27#include "inout.h"
    2728#include "list.h"
    2829#include "peer-connection.h"
     
    5960{
    6061    AWAITING_BT_LENGTH,
    61     AWAITING_BT_MESSAGE
     62    AWAITING_BT_MESSAGE,
     63    READING_BT_PIECE
    6264};
    6365
     
    7375    fprintf (stderr, "PeerManager::getStateName: unhandled state %d\n", state );
    7476    abort( );
     77}
     78
     79struct peer_request
     80{
     81    uint32_t pieceIndex;
     82    uint32_t offsetInPiece;
     83    uint32_t length;
     84};
     85
     86static int
     87peer_request_compare_func( const void * va, const void * vb )
     88{
     89    struct peer_request * a = (struct peer_request*) va;
     90    struct peer_request * b = (struct peer_request*) vb;
     91    if( a->pieceIndex != b->pieceIndex )
     92        return a->pieceIndex - b->pieceIndex;
     93    if( a->offsetInPiece != b->offsetInPiece )
     94        return a->offsetInPiece - b->offsetInPiece;
     95    if( a->length != b->length )
     96        return a->length - b->length;
     97    return 0;
    7598}
    7699
     
    80103    tr_torrent * torrent;
    81104    tr_peerConnection * connection;
    82     tr_bitfield * bitfield; /* the peer's bitfield */
    83     tr_bitfield * banfield; /* bad pieces from the peer */
     105    tr_bitfield * bitfield;   /* the peer's bitfield */
     106    tr_bitfield * banfield;   /* bad pieces from the peer */
     107    tr_bitfield * blamefield; /* lists pieces that this peer helped us with */
    84108
    85109    struct evbuffer * outMessages; /* buffer of all the non-piece messages */
     110    struct evbuffer * outBlock;    /* the block we're currently sending */
     111    struct evbuffer * inBlock;     /* the block we're currently receiving */
     112    tr_list * peerAskedFor;
    86113    tr_list * outPieces;
    87114
    88115    tr_timer_tag pulseTag;
    89116
    90     tr_ratecontrol * rcIn;  /* rate of bytes from the peer to us */
    91     tr_ratecontrol * rcOut; /* rate of bytes from us to the peer */
    92 
    93     unsigned int  weAreChokingThem  : 1;
    94     unsigned int  peerisChokingUs   : 1;
    95     unsigned int  weAreInterested   : 1;
    96     unsigned int  peerIsInterested  : 1;
    97     unsigned int  isPrivate         : 1;
     117    tr_ratecontrol * rcToUs;   /* rate of bytes from the peer to us */
     118    tr_ratecontrol * rcToPeer; /* rate of bytes from us to the peer */
     119
     120    unsigned int  peerIsChoked        : 1;
     121    unsigned int  weAreChoked         : 1;
     122    unsigned int  peerIsInterested    : 1;
     123    unsigned int  weAreInterested     : 1;
     124    unsigned int  isPrivate           : 1;
     125    unsigned int  notListening        : 1;
     126
     127    struct peer_request blockToUs;
    98128
    99129    int state;
     
    106136
    107137    uint16_t ut_pex;
    108     uint32_t listeningPort;
     138    uint16_t listeningPort;
    109139
    110140    /* the client name from the `v' string in LTEP's handshake dictionary */
     
    171201}
    172202
     203void
     204setChoke( tr_peer * peer, int choke )
     205{
     206    if( peer->peerIsChoked != !!choke )
     207    {
     208        const uint32_t len = sizeof(uint8_t);
     209        const uint8_t bt_msgid = choke ? BT_CHOKE : BT_UNCHOKE;
     210
     211        peer->peerIsChoked = choke ? 1 : 0;
     212        if( peer->peerIsChoked )
     213        {
     214            tr_list_foreach( peer->peerAskedFor, tr_free );
     215            tr_list_free( &peer->peerAskedFor );
     216        }
     217
     218        fprintf( stderr, "peer %p: enqueuing a %s message\n", peer, (choke ? "choke" : "unchoke") );
     219        tr_peerConnectionWriteUint32( peer->connection, peer->outMessages, len );
     220        tr_peerConnectionWriteBytes( peer->connection, peer->outMessages, &bt_msgid, 1 );
     221    }
     222}
     223
    173224/**
    174225***
     
    208259for( i=0; i<sub->val.s.i; ++i ) fprintf( stderr, "[%c] (%d)\n", sub->val.s.s[i], (int)sub->val.s.s[i] );
    209260        peer->client = tr_strndup( sub->val.s.s, sub->val.s.i );
    210         for( i=0; i<sub->val.s.i; ++i )
    211             if( !isprint(peer->client[i])) peer->client[i]='u';
    212261        fprintf( stderr, "peer->client is now [%s]\n", peer->client );
    213262    }
     
    217266    if( tr_bencIsInt( sub ) ) {
    218267        peer->listeningPort = htons( (uint16_t)sub->val.i );
    219         fprintf( stderr, "peer->port is now %d\n", peer->listeningPort );
     268        fprintf( stderr, "peer->port is now %hd\n", peer->listeningPort );
    220269    }
    221270
     
    311360    tr_peerConnectionReadBytes( peer->connection, inbuf, &id, 1 );
    312361    msglen--;
    313     fprintf( stderr, "got a message from the peer... bt id number is %d, and remaining len is %d\n", (int)id, (int)msglen );
     362    fprintf( stderr, "got a message from the peer... "
     363                     "bt id number is %d, and remaining len is %d\n", (int)id, (int)msglen );
    314364
    315365    switch( id )
    316366    {
    317367        case BT_CHOKE:
     368            assert( msglen == 0 );
    318369            fprintf( stderr, "got a BT_CHOKE\n" );
    319             peer->peerisChokingUs = 1;
     370            peer->weAreChoked = 1;
     371            tr_list_foreach( peer->peerAskedFor, tr_free );
     372            tr_list_free( &peer->peerAskedFor );
    320373            /* FIXME: maybe choke them */
    321             /* FIXME: clear their outPieces queue */
    322             /* FIXME: unmark those outpieces as requested */
     374            /* FIXME: unmark anything we'd requested from them... */
    323375            break;
    324376
    325377        case BT_UNCHOKE:
     378            assert( msglen == 0 );
    326379            fprintf( stderr, "got a BT_UNCHOKE\n" );
    327             peer->peerisChokingUs = 0;
     380            peer->weAreChoked = 0;
    328381            /* FIXME: maybe unchoke them */
    329382            /* FIXME: maybe send them requests */
     
    331384
    332385        case BT_INTERESTED:
     386            assert( msglen == 0 );
    333387            fprintf( stderr, "got a BT_INTERESTED\n" );
    334388            peer->peerIsInterested = 1;
     
    337391
    338392        case BT_NOT_INTERESTED:
     393            assert( msglen == 0 );
    339394            fprintf( stderr, "got a BT_NOT_INTERESTED\n" );
    340395            peer->peerIsInterested = 0;
     
    343398
    344399        case BT_HAVE:
     400            assert( msglen == 4 );
    345401            fprintf( stderr, "got a BT_HAVE\n" );
    346402            tr_peerConnectionReadUint32( peer->connection, inbuf, &ui32 );
     
    351407
    352408        case BT_BITFIELD:
     409            assert( msglen == peer->bitfield->len );
    353410            fprintf( stderr, "got a BT_BITFIELD\n" );
    354             assert( msglen == peer->bitfield->len );
    355411            tr_peerConnectionReadBytes( peer->connection, inbuf, peer->bitfield->bits, msglen );
    356412            peer->progress = tr_bitfieldCountTrueBits( peer->bitfield ) / (float)peer->torrent->info.pieceCount;
     
    360416            break;
    361417
    362         case BT_REQUEST:
     418        case BT_REQUEST: {
     419            struct peer_request * req;
     420            assert( msglen == 12 );
    363421            fprintf( stderr, "got a BT_REQUEST\n" );
    364             break;
    365 
    366         case BT_PIECE:
     422            req = tr_new( struct peer_request, 1 );
     423            tr_peerConnectionReadUint32( peer->connection, inbuf, &req->pieceIndex );
     424            tr_peerConnectionReadUint32( peer->connection, inbuf, &req->offsetInPiece );
     425            tr_peerConnectionReadUint32( peer->connection, inbuf, &req->length );
     426            if( !peer->peerIsChoked )
     427                tr_list_append( &peer->peerAskedFor, req );
     428            break;
     429        }
     430
     431        case BT_CANCEL: {
     432            struct peer_request req;
     433            tr_list * node;
     434            assert( msglen == 12 );
     435            fprintf( stderr, "got a BT_CANCEL\n" );
     436            tr_peerConnectionReadUint32( peer->connection, inbuf, &req.pieceIndex );
     437            tr_peerConnectionReadUint32( peer->connection, inbuf, &req.offsetInPiece );
     438            tr_peerConnectionReadUint32( peer->connection, inbuf, &req.length );
     439            node = tr_list_find( peer->peerAskedFor, &req, peer_request_compare_func );
     440            if( node != NULL ) {
     441                fprintf( stderr, "found the req that peer is cancelling... cancelled.\n" );
     442                tr_list_remove_data( &peer->peerAskedFor, node->data );
     443            }
     444            break;
     445        }
     446
     447        case BT_PIECE: {
    367448            fprintf( stderr, "got a BT_PIECE\n" );
    368             break;
    369 
    370         case BT_CANCEL:
    371             fprintf( stderr, "got a BT_CANCEL\n" );
    372             break;
    373 
    374         case BT_PORT:
     449            assert( peer->blockToUs.length == 0 );
     450            peer->state = READING_BT_PIECE;
     451            tr_peerConnectionReadUint32( peer->connection, inbuf, &peer->blockToUs.pieceIndex );
     452            tr_peerConnectionReadUint32( peer->connection, inbuf, &peer->blockToUs.offsetInPiece );
     453            peer->blockToUs.length = msglen - 8;
     454            assert( peer->blockToUs.length > 0 );
     455            evbuffer_drain( peer->inBlock, ~0 );
     456            break;
     457        }
     458
     459        case BT_PORT: {
     460            assert( msglen == 2 );
    375461            fprintf( stderr, "got a BT_PORT\n" );
    376             break;
     462            tr_peerConnectionReadUint16( peer->connection, inbuf, &peer->listeningPort );
     463            break;
     464        }
    377465
    378466        case BT_LTEP:
     
    383471        default:
    384472            fprintf( stderr, "got an unknown BT message type: %d\n", (int)id );
     473            tr_peerConnectionDrain( peer->connection, inbuf, msglen );
    385474            assert( 0 );
    386475    }
     
    389478    peer->state = AWAITING_BT_LENGTH;
    390479    return READ_AGAIN;
     480}
     481
     482static int
     483canDownload( const tr_peer * peer )
     484{
     485    tr_torrent * tor = peer->torrent;
     486
     487#if 0
     488    /* FIXME: was swift worth it?  did anyone notice a difference? :) */
     489    if( SWIFT_ENABLED && !isSeeding && (peer->credit<0) )
     490        return FALSE;
     491#endif
     492
     493    if( tor->downloadLimitMode == TR_SPEEDLIMIT_GLOBAL )
     494        return !tor->handle->useDownloadLimit || tr_rcCanTransfer( tor->handle->download );
     495
     496    if( tor->downloadLimitMode == TR_SPEEDLIMIT_SINGLE )
     497        return tr_rcCanTransfer( tor->download );
     498
     499    return TRUE;
     500}
     501
     502static void
     503gotBlock( tr_peer * peer, int pieceIndex, int offset, struct evbuffer * inbuf )
     504{
     505    tr_torrent * tor = peer->torrent;
     506    const size_t len = EVBUFFER_LENGTH( inbuf );
     507    const int block = _tr_block( tor, pieceIndex, offset );
     508
     509    /* sanity clause */
     510    if( tr_cpBlockIsComplete( tor->completion, block ) ) {
     511        tr_dbg( "have this block already..." );
     512        return;
     513    }
     514    if( (int)len != tr_torBlockCountBytes( tor, block ) ) {
     515        tr_dbg( "block is the wrong length..." );
     516        return;
     517    }
     518
     519    /* write to disk */
     520    if( tr_ioWrite( tor, pieceIndex, offset, len, EVBUFFER_DATA( inbuf )))
     521        return;
     522
     523    /* make a note that this peer helped us with this piece */
     524    if( !peer->blamefield )
     525         peer->blamefield = tr_bitfieldNew( tor->info.pieceCount );
     526    tr_bitfieldAdd( peer->blamefield, pieceIndex );
     527
     528    tr_cpBlockAdd( tor->completion, block );
     529
     530    tor->downloadedCur += len;
     531    tr_rcTransferred( peer->rcToUs, len );
     532    tr_rcTransferred( tor->download, len );
     533    tr_rcTransferred( tor->handle->download, len );
     534
     535//    broadcastCancel( tor, index, begin, len - 8 );
     536}
     537
     538
     539static ReadState
     540readBtPiece( tr_peer * peer, struct evbuffer * inbuf )
     541{
     542    assert( peer->blockToUs.length > 0 );
     543
     544    if( !canDownload( peer ) )
     545    {
     546        peer->notListening = 1;
     547        tr_peerConnectionSetIOMode ( peer->connection, 0, EV_READ );
     548        return READ_DONE;
     549    }
     550    else
     551    {
     552        /* inbuf ->  inBlock */
     553        const uint32_t len = MIN( EVBUFFER_LENGTH(inbuf), peer->blockToUs.length );
     554        uint8_t * tmp = tr_new( uint8_t, len );
     555        tr_peerConnectionReadBytes( peer->connection, inbuf, tmp, len );
     556        evbuffer_add( peer->inBlock, tmp, len );
     557        tr_free( tmp );
     558        peer->blockToUs.length -= len;
     559
     560        if( !peer->blockToUs.length )
     561        {
     562            gotBlock( peer, peer->blockToUs.pieceIndex,
     563                            peer->blockToUs.offsetInPiece,
     564                            peer->inBlock );
     565            evbuffer_drain( peer->outBlock, ~0 );
     566            peer->state = AWAITING_BT_LENGTH;
     567        }
     568
     569        return READ_AGAIN;
     570    }
    391571}
    392572
     
    403583        case AWAITING_BT_LENGTH:  ret = readBtLength  ( peer, inbuf ); break;
    404584        case AWAITING_BT_MESSAGE: ret = readBtMessage ( peer, inbuf ); break;
     585        case READING_BT_PIECE:    ret = readBtPiece   ( peer, inbuf ); break;
    405586        default: assert( 0 );
    406587    }
    407588    return ret;
    408 }
    409 
    410 static void
    411 didWrite( struct bufferevent * evin UNUSED, void * vpeer )
    412 {
    413     tr_peer * peer = (tr_peer *) vpeer;
    414     fprintf( stderr, "peer %p got a didWrite...\n", peer );
    415 }
    416 
    417 static void
    418 gotError( struct bufferevent * evbuf UNUSED, short what, void * vpeer )
    419 {
    420     tr_peer * peer = (tr_peer *) vpeer;
    421     fprintf( stderr, "peer %p got an error in %d\n", peer, (int)what );
    422589}
    423590
     
    427594
    428595static int
     596canUpload( const tr_peer * peer )
     597{
     598    const tr_torrent * tor = peer->torrent;
     599
     600    if( tor->uploadLimitMode == TR_SPEEDLIMIT_GLOBAL )
     601        return !tor->handle->useUploadLimit || tr_rcCanTransfer( tor->handle->upload );
     602
     603    if( tor->uploadLimitMode == TR_SPEEDLIMIT_SINGLE )
     604        return tr_rcCanTransfer( tor->upload );
     605
     606    return TRUE;
     607}
     608
     609static int
    429610pulse( void * vpeer )
    430611{
    431612    tr_peer * peer = (tr_peer *) vpeer;
    432 
    433     /* send out the non-piece messages. */
    434     if( EVBUFFER_LENGTH( peer->outMessages ) ) {
    435         fprintf( stderr, "peer %p pulse is writing %d bytes worth of messages...\n", peer, (int)EVBUFFER_LENGTH(peer->outMessages) );
     613    size_t len;
     614
     615    /* if we froze out a downloaded block because of speed limits,
     616       start listening to the peer again */
     617    if( peer->notListening )
     618    {
     619        fprintf( stderr, "peer %p thawing out...\n", peer );
     620        peer->notListening = 0;
     621        tr_peerConnectionSetIOMode ( peer->connection, EV_READ, 0 );
     622    }
     623
     624    if(( len = EVBUFFER_LENGTH( peer->outBlock ) ))
     625    {
     626        if( canUpload( peer ) )
     627        {
     628            const size_t outlen = MIN( len, 2048 );
     629            tr_peerConnectionWrite( peer->connection, EVBUFFER_DATA(peer->outBlock), outlen );
     630            evbuffer_drain( peer->outBlock, outlen );
     631        }
     632    }
     633    else if(( len = EVBUFFER_LENGTH( peer->outMessages ) ))
     634    {
     635        fprintf( stderr, "peer %p pulse is writing %d bytes worth of messages...\n", peer, (int)len );
    436636        tr_peerConnectionWriteBuf( peer->connection, peer->outMessages );
    437         evbuffer_drain( peer->outMessages, EVBUFFER_LENGTH( peer->outMessages ) );
    438     }
    439 
    440     return TRUE;
     637        evbuffer_drain( peer->outMessages, ~0 );
     638    }
     639    else if(( peer->peerAskedFor ))
     640    {
     641        struct peer_request * req = (struct peer_request*) peer->peerAskedFor->data;
     642        uint8_t * tmp = tr_new( uint8_t, req->length );
     643        const uint8_t msgid = BT_PIECE;
     644        const uint32_t msglen = sizeof(uint8_t) + sizeof(uint32_t)*2 + req->length;
     645        tr_ioRead( peer->torrent, req->pieceIndex, req->offsetInPiece, req->length, tmp );
     646        tr_peerConnectionWriteUint32( peer->connection, peer->outBlock, msglen );
     647        tr_peerConnectionWriteBytes ( peer->connection, peer->outBlock, &msgid, 1 );
     648        tr_peerConnectionWriteUint32( peer->connection, peer->outBlock, req->pieceIndex );
     649        tr_peerConnectionWriteUint32( peer->connection, peer->outBlock, req->offsetInPiece );
     650        tr_peerConnectionWriteBytes ( peer->connection, peer->outBlock, tmp, req->length );
     651        tr_free( tmp );
     652    }
     653
     654    return TRUE; /* loop forever */
     655}
     656
     657static void
     658didWrite( struct bufferevent * evin UNUSED, void * vpeer )
     659{
     660    tr_peer * peer = (tr_peer *) vpeer;
     661    fprintf( stderr, "peer %p got a didWrite...\n", peer );
     662    pulse( vpeer );
     663}
     664
     665static void
     666gotError( struct bufferevent * evbuf UNUSED, short what, void * vpeer )
     667{
     668    tr_peer * peer = (tr_peer *) vpeer;
     669    fprintf( stderr, "peer %p got an error in %d\n", peer, (int)what );
    441670}
    442671
     
    464693    peer->torrent = torrent;
    465694    peer->connection = connection;
    466     peer->rcIn = tr_rcInit( );
    467     peer->rcOut = tr_rcInit( );
    468     peer->weAreChokingThem = 1;
    469     peer->peerisChokingUs = 1;
     695    peer->weAreChoked = 1;
     696    peer->peerIsChoked = 1;
    470697    peer->weAreInterested = 0;
    471698    peer->peerIsInterested = 0;
     
    473700    peer->bitfield = tr_bitfieldNew( torrent->info.pieceCount );
    474701    peer->outMessages = evbuffer_new( );
     702    peer->outBlock = evbuffer_new( );
     703    peer->inBlock = evbuffer_new( );
    475704
    476705    tr_peerConnectionSetIOFuncs( connection, canRead, didWrite, gotError, peer );
     
    479708    sendBitfield( peer );
    480709}
     710
     711void
     712tr_peerGetInfo( const tr_peer * peer, tr_peer_stat * setme )
     713{
     714    setme->client = peer->client;
     715    setme->isConnected = TRUE;
     716    setme->progress = peer->progress;
     717    setme->downloadFromRate = tr_rcRate( peer->rcToUs );
     718    setme->downloadFromRate = tr_rcRate( peer->rcToPeer );
     719
     720    //char    addr[INET_ADDRSTRLEN];
     721    //int     from;
     722    //int     port;
     723    //int     isDownloading;
     724    //int     isUploading;
     725
     726}
  • branches/encryption/libtransmission/peer-connection.c

    r2946 r2949  
    419419    *setme = ntohl( tmp );
    420420}
     421
     422void
     423tr_peerConnectionDrain( tr_peerConnection   * conn,
     424                        struct evbuffer     * inbuf,
     425                        int                   byteCount )
     426{
     427    uint8_t * tmp = tr_new( uint8_t, byteCount );
     428    tr_peerConnectionReadBytes( conn, inbuf, tmp, byteCount );
     429    tr_free( tmp );
     430}
  • branches/encryption/libtransmission/peer-connection.h

    r2946 r2949  
    152152                                    uint32_t            * setme );
    153153
     154void tr_peerConnectionDrain       ( tr_peerConnection   * conn,
     155                                    struct evbuffer     * inbuf,
     156                                    int                   byteCount );
     157
    154158
    155159#endif
  • branches/encryption/libtransmission/peermessages.h

    r2941 r2949  
    144144        buf += 4;
    145145
    146         tr_ioRead( tor->io, r->index, r->begin, r->length, buf );
     146        tr_ioRead( tor, r->index, r->begin, r->length, buf );
    147147
    148148        peer_dbg( "SEND piece %d/%d (%d bytes)",
  • branches/encryption/libtransmission/peerparse.h

    r2942 r2949  
    335335
    336336    /* Write to disk */
    337     if( ( ret = tr_ioWrite( tor->io, index, begin, len - 8, &p[8] ) ) )
     337    if( ( ret = tr_ioWrite( tor, index, begin, len - 8, &p[8] ) ) )
    338338    {
    339339        return ret;
  • branches/encryption/libtransmission/torrent.c

    r2942 r2949  
    894894***/
    895895
    896 tr_peer_stat_t *
     896tr_peer_stat *
    897897tr_torrentPeers( const tr_torrent * tor, int * peerCount )
    898898{
    899     tr_peer_stat_t * peers;
     899    tr_peer_stat * peers;
    900900
    901901    tr_torrentReaderLock( tor );
     
    903903    *peerCount = tor->peerCount;
    904904   
    905     peers = tr_new0( tr_peer_stat_t, tor->peerCount );
     905    peers = tr_new0( tr_peer_stat, tor->peerCount );
    906906    if (peers != NULL)
    907907    {
     
    939939}
    940940
    941 void tr_torrentPeersFree( tr_peer_stat_t * peers, int peerCount UNUSED )
     941void tr_torrentPeersFree( tr_peer_stat * peers, int peerCount UNUSED )
    942942{
    943943    tr_free( peers );
  • branches/encryption/libtransmission/transmission.h

    r2944 r2949  
    471471 * tr_torrentPeers
    472472 ***********************************************************************/
    473 typedef struct tr_peer_stat_s tr_peer_stat_t;
    474 tr_peer_stat_t * tr_torrentPeers( const tr_torrent *, int * peerCount );
    475 void tr_torrentPeersFree( tr_peer_stat_t *, int peerCount );
     473typedef struct tr_peer_stat tr_peer_stat;
     474typedef struct tr_peer_stat tr_peer_stat_t;
     475tr_peer_stat * tr_torrentPeers( const tr_torrent *, int * peerCount );
     476void tr_torrentPeersFree( tr_peer_stat *, int peerCount );
    476477
    477478typedef struct tr_file_stat_s tr_file_stat_t;
     
    652653};
    653654
    654 struct tr_peer_stat_s
     655struct tr_peer_stat
    655656{
    656657    char    addr[INET_ADDRSTRLEN];
Note: See TracChangeset for help on using the changeset viewer.