Changeset 6548


Ignore:
Timestamp:
Aug 16, 2008, 5:11:28 AM (15 years ago)
Author:
charles
Message:

(libT) route all outbound peer protocol messages through the outMessages buffer, to ensure that they're sent in sequence. previously the outbound pex message wasn't queued in this way.

File:
1 edited

Legend:

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

    r6525 r6548  
    389389    tr_peerIoWriteUint32( io, out, req->length );
    390390    pokeBatchPeriod( msgs, HIGH_PRIORITY_INTERVAL_SECS );
     391    dbgmsg( msgs, "outMessage size is now %d", (int)EVBUFFER_LENGTH(out) );
    391392}
    392393
     
    404405    tr_peerIoWriteUint32( io, out, req->length );
    405406    pokeBatchPeriod( msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS );
     407    dbgmsg( msgs, "outMessage size is now %d", (int)EVBUFFER_LENGTH(out) );
    406408}
    407409
     
    417419    tr_peerIoWriteUint32( io, out, index );
    418420    pokeBatchPeriod( msgs, LOW_PRIORITY_INTERVAL_SECS );
     421    dbgmsg( msgs, "outMessage size is now %d", (int)EVBUFFER_LENGTH(out) );
    419422}
    420423
     
    429432    tr_peerIoWriteUint8 ( io, out, choke ? BT_CHOKE : BT_UNCHOKE );
    430433    pokeBatchPeriod( msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS );
     434    dbgmsg( msgs, "outMessage size is now %d", (int)EVBUFFER_LENGTH(out) );
    431435}
    432436
     
    552556sendInterest( tr_peermsgs * msgs, int weAreInterested )
    553557{
     558    struct evbuffer * out = msgs->outMessages;
     559
    554560    assert( msgs );
    555561    assert( weAreInterested==0 || weAreInterested==1 );
    556562
    557563    msgs->info->clientIsInterested = weAreInterested;
    558     dbgmsg( msgs, "Sending %s",
    559             weAreInterested ? "Interested" : "Not Interested");
    560 
    561     tr_peerIoWriteUint32( msgs->io, msgs->outMessages, sizeof(uint8_t) );
    562     tr_peerIoWriteUint8 ( msgs->io, msgs->outMessages,
    563                    weAreInterested ? BT_INTERESTED : BT_NOT_INTERESTED );
     564    dbgmsg( msgs, "Sending %s", weAreInterested ? "Interested" : "Not Interested");
     565    tr_peerIoWriteUint32( msgs->io, out, sizeof(uint8_t) );
     566    tr_peerIoWriteUint8 ( msgs->io, out, weAreInterested ? BT_INTERESTED : BT_NOT_INTERESTED );
    564567    pokeBatchPeriod( msgs, HIGH_PRIORITY_INTERVAL_SECS );
     568    dbgmsg( msgs, "outMessage size is now %d", (int)EVBUFFER_LENGTH(out) );
    565569}
    566570
     
    656660    if( tr_peerIoSupportsFEXT( msgs->io ) )
    657661    {
     662        struct evbuffer * out = msgs->outMessages;
    658663        const uint32_t len = sizeof(uint8_t) + 3 * sizeof(uint32_t);
    659         tr_peerIoWriteUint32( msgs->io, msgs->outMessages, len );
    660         tr_peerIoWriteUint8( msgs->io, msgs->outMessages, BT_REJECT );
    661         tr_peerIoWriteUint32( msgs->io, msgs->outMessages, pieceIndex );
    662         tr_peerIoWriteUint32( msgs->io, msgs->outMessages, offset );
    663         tr_peerIoWriteUint32( msgs->io, msgs->outMessages, length );
     664        dbgmsg( msgs, "sending fast reject %u:%u->%u", pieceIndex, offset, length );
     665        tr_peerIoWriteUint32( msgs->io, out, len );
     666        tr_peerIoWriteUint8( msgs->io, out, BT_REJECT );
     667        tr_peerIoWriteUint32( msgs->io, out, pieceIndex );
     668        tr_peerIoWriteUint32( msgs->io, out, offset );
     669        tr_peerIoWriteUint32( msgs->io, out, length );
    664670        pokeBatchPeriod( msgs, LOW_PRIORITY_INTERVAL_SECS );
     671        dbgmsg( msgs, "outMessage size is now %d", (int)EVBUFFER_LENGTH(out) );
    665672    }
    666673}
     
    689696    if( tr_peerIoSupportsFEXT( msgs->io ) )
    690697    {
    691         tr_peerIoWriteUint32( msgs->io, msgs->outMessages, sizeof(uint8_t) + sizeof(uint32_t) );
    692         tr_peerIoWriteUint8( msgs->io, msgs->outMessages, BT_ALLOWED_FAST );
    693         tr_peerIoWriteUint32( msgs->io, msgs->outMessages, pieceIndex );
     698        struct evbuffer * out = msgs->outMessages;
     699        dbgmsg( msgs, "sending fast allowed" );
     700        tr_peerIoWriteUint32( msgs->io, out,  sizeof(uint8_t) + sizeof(uint32_t) );
     701        tr_peerIoWriteUint8( msgs->io, out, BT_ALLOWED_FAST );
     702        tr_peerIoWriteUint32( msgs->io, out, pieceIndex );
    694703        pokeBatchPeriod( msgs, LOW_PRIORITY_INTERVAL_SECS );
     704        dbgmsg( msgs, "outMessage size is now %d", (int)EVBUFFER_LENGTH(out) );
    695705    }
    696706}
     
    925935    int len;
    926936    int pex;
    927     struct evbuffer * outbuf;
     937    struct evbuffer * out = msgs->outMessages;
    928938
    929939    if( msgs->clientSentLtepHandshake )
    930940        return;
    931941
    932     outbuf = evbuffer_new( );
    933942    dbgmsg( msgs, "sending an ltep handshake" );
    934943    msgs->clientSentLtepHandshake = 1;
     
    951960    buf = tr_bencSave( &val, &len );
    952961
    953     tr_peerIoWriteUint32( msgs->io, outbuf, 2*sizeof(uint8_t) + len );
    954     tr_peerIoWriteUint8 ( msgs->io, outbuf, BT_LTEP );
    955     tr_peerIoWriteUint8 ( msgs->io, outbuf, LTEP_HANDSHAKE );
    956     tr_peerIoWriteBytes ( msgs->io, outbuf, buf, len );
    957 
    958     tr_peerIoWriteBuf( msgs->io, outbuf );
    959 
    960     dbgmsg( msgs, "here is the ltep handshake we sent [%*.*s]", len, len, buf );
     962    tr_peerIoWriteUint32( msgs->io, out, 2*sizeof(uint8_t) + len );
     963    tr_peerIoWriteUint8 ( msgs->io, out, BT_LTEP );
     964    tr_peerIoWriteUint8 ( msgs->io, out, LTEP_HANDSHAKE );
     965    tr_peerIoWriteBytes ( msgs->io, out, buf, len );
     966    pokeBatchPeriod( msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS );
     967    dbgmsg( msgs, "outMessage size is now %d", (int)EVBUFFER_LENGTH(out) );
    961968
    962969    /* cleanup */
    963970    tr_bencFree( &val );
    964971    tr_free( buf );
    965     evbuffer_free( outbuf );
    966972}
    967973
     
    17531759    tr_peerIoWriteBytes ( msgs->io, out, bitfield->bits, bitfield->byteCount );
    17541760    pokeBatchPeriod( msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS );
     1761    dbgmsg( msgs, "outMessage size is now %d", (int)EVBUFFER_LENGTH(out) );
    17551762}
    17561763
     
    18201827        char * benc;
    18211828        int bencLen;
     1829        struct evbuffer * out = msgs->outMessages;
    18221830
    18231831        /* build the diffs */
     
    18721880        /* write the pex message */
    18731881        benc = tr_bencSave( &val, &bencLen );
    1874         tr_peerIoWriteUint32( msgs->io, msgs->outMessages, 2*sizeof(uint8_t) + bencLen );
    1875         tr_peerIoWriteUint8 ( msgs->io, msgs->outMessages, BT_LTEP );
    1876         tr_peerIoWriteUint8 ( msgs->io, msgs->outMessages, msgs->ut_pex_id );
    1877         tr_peerIoWriteBytes ( msgs->io, msgs->outMessages, benc, bencLen );
     1882        tr_peerIoWriteUint32( msgs->io, out, 2*sizeof(uint8_t) + bencLen );
     1883        tr_peerIoWriteUint8 ( msgs->io, out, BT_LTEP );
     1884        tr_peerIoWriteUint8 ( msgs->io, out, msgs->ut_pex_id );
     1885        tr_peerIoWriteBytes ( msgs->io, out, benc, bencLen );
    18781886        pokeBatchPeriod( msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS );
     1887        dbgmsg( msgs, "outMessage size is now %d", (int)EVBUFFER_LENGTH(out) );
    18791888
    18801889        /* cleanup */
Note: See TracChangeset for help on using the changeset viewer.