Ignore:
Timestamp:
Dec 16, 2008, 10:08:17 PM (12 years ago)
Author:
charles
Message:

(trunk libT) really fuck up the peer i/o code. also this breaks the mac build until someone removes iobuf.c from libtransmission's list of files.

File:
1 edited

Legend:

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

    r7404 r7419  
    2525#include "crypto.h"
    2626#include "inout.h"
    27 #include "iobuf.h"
    2827#ifdef WIN32
    2928#include "net.h" /* for ECONN */
     
    875874    struct request_list tmp = REQUEST_LIST_INIT;
    876875    const tr_bool fext = tr_peerIoSupportsFEXT( msgs->peer->io );
     876    dbgmsg( msgs, "entering `expire old requests' block" );
    877877
    878878    /* cancel requests that have been queued for too long */
     
    898898        reqListClear( &tmp );
    899899    }
     900
     901    dbgmsg( msgs, "leaving `expire old requests' block" );
    900902}
    901903
     
    10551057    /* if it's only in the queue and hasn't been sent yet, free it */
    10561058    if( reqListRemove( &msgs->clientWillAskFor, &req ) ) {
    1057         dbgmsg( msgs, "cancelling %"PRIu32":%"PRIu32"->%"PRIu32"\n", pieceIndex, offset, length );
     1059        dbgmsg( msgs, "cancelling %"PRIu32":%"PRIu32"->%"PRIu32, pieceIndex, offset, length );
    10581060        fireCancelledReq( msgs, &req );
    10591061    }
     
    10611063    /* if it's already been sent, send a cancel message too */
    10621064    if( reqListRemove( &msgs->clientAskedFor, &req ) ) {
    1063         dbgmsg( msgs, "cancelling %"PRIu32":%"PRIu32"->%"PRIu32"\n", pieceIndex, offset, length );
     1065        dbgmsg( msgs, "cancelling %"PRIu32":%"PRIu32"->%"PRIu32, pieceIndex, offset, length );
    10641066        protocolSendCancel( msgs, &req );
    10651067        fireCancelledReq( msgs, &req );
     
    17221724
    17231725static ReadState
    1724 canRead( struct tr_iobuf * iobuf, void * vmsgs, size_t * piece )
     1726canRead( tr_peerIo * io, void * vmsgs, size_t * piece )
    17251727{
    17261728    ReadState         ret;
    17271729    tr_peermsgs *     msgs = vmsgs;
    1728     struct evbuffer * in = tr_iobuf_input( iobuf );
     1730    struct evbuffer * in = tr_peerIoGetReadBuffer( io );
    17291731    const size_t      inlen = EVBUFFER_LENGTH( in );
    17301732
     
    17681770    tr_peermsgs * msgs = vmsgs;
    17691771    const double rateToClient = tr_peerGetPieceSpeed( msgs->peer, TR_PEER_TO_CLIENT );
    1770     const int estimatedBlocksInNext30Seconds =
    1771                   ( rateToClient * 30 * 1024 ) / msgs->torrent->blockSize;
     1772    const int seconds = 10;
     1773    const int estimatedBlocksInPeriod = ( rateToClient * seconds * 1024 ) / msgs->torrent->blockSize;
     1774
    17721775    msgs->minActiveRequests = 8;
    1773     msgs->maxActiveRequests = msgs->minActiveRequests + estimatedBlocksInNext30Seconds;
     1776    msgs->maxActiveRequests = msgs->minActiveRequests + estimatedBlocksInPeriod;
     1777
    17741778    if( msgs->reqq > 0 )
    17751779        msgs->maxActiveRequests = MIN( msgs->maxActiveRequests, msgs->reqq );
     1780
    17761781    return TRUE;
    17771782}
     
    18821887tr_peerMsgsPulse( tr_peermsgs * msgs )
    18831888{
    1884     if( msgs != NULL )
     1889    if( msgs )
    18851890        peerPulse( msgs );
    18861891}
    18871892
    18881893static void
    1889 gotError( struct tr_iobuf  * iobuf UNUSED,
    1890           short              what,
    1891           void             * vmsgs )
     1894gotError( tr_peerIo  * io UNUSED,
     1895          short        what,
     1896          void       * vmsgs )
    18921897{
    18931898    if( what & EVBUFFER_TIMEOUT )
     
    22402245    tellPeerWhatWeHave( m );
    22412246
    2242     tr_peerIoSetTimeoutSecs( m->peer->io, 150 ); /* timeout after N seconds of inactivity */
    22432247    tr_peerIoSetIOFuncs( m->peer->io, canRead, didWrite, gotError, m );
    22442248    ratePulse( m );
Note: See TracChangeset for help on using the changeset viewer.