Changeset 7136


Ignore:
Timestamp:
Nov 23, 2008, 4:30:09 PM (12 years ago)
Author:
charles
Message:

minor code cleanup

Location:
trunk/libtransmission
Files:
3 edited

Legend:

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

    r7130 r7136  
    345345}
    346346
    347 #define dbgmsg( msgs, ... ) myDebug( __FILE__, __LINE__, msgs, __VA_ARGS__ )
     347#define dbgmsg( msgs, ... ) \
     348    do { \
     349        if( tr_deepLoggingIsActive( ) ) \
     350            myDebug( __FILE__, __LINE__, msgs, __VA_ARGS__ ); \
     351    } while( 0 )
    348352
    349353/**
     
    911915    **/
    912916
    913     dbgmsg( msgs, "added req for piece %lu", (unsigned long)index );
     917    dbgmsg( msgs, "adding req for %"PRIu32":%"PRIu32"->%"PRIu32" to our `will request' list",
     918            index, offset, length );
    914919    req.time_requested = time( NULL );
    915920    reqListAppend( &msgs->clientWillAskFor, &req );
     
    923928    struct request_list a = msgs->clientWillAskFor;
    924929    struct request_list b = msgs->clientAskedFor;
     930    dbgmsg( msgs, "cancelling all requests to peer" );
    925931
    926932    msgs->clientAskedFor = REQUEST_LIST_INIT;
     
    950956    assert( length > 0 );
    951957
     958
    952959    /* have we asked the peer for this piece? */
    953960    req.index = pieceIndex;
     
    956963
    957964    /* if it's only in the queue and hasn't been sent yet, free it */
    958     if( reqListRemove( &msgs->clientWillAskFor, &req ) )
     965    if( reqListRemove( &msgs->clientWillAskFor, &req ) ) {
     966        dbgmsg( msgs, "cancelling %"PRIu32":%"PRIu32"->%"PRIu32"\n", pieceIndex, offset, length );
    959967        fireCancelledReq( msgs, &req );
     968    }
    960969
    961970    /* if it's already been sent, send a cancel message too */
    962971    if( reqListRemove( &msgs->clientAskedFor, &req ) ) {
     972        dbgmsg( msgs, "cancelling %"PRIu32":%"PRIu32"->%"PRIu32"\n", pieceIndex, offset, length );
    963973        protocolSendCancel( msgs, &req );
    964974        fireCancelledReq( msgs, &req );
     
    10341044    }
    10351045
    1036     dbgmsg( msgs, "here is the ltep handshake we got [%*.*s]", len, len,
    1037             tmp );
     1046    dbgmsg( msgs, "here is the handshake: [%*.*s]", len, len,  tmp );
    10381047
    10391048    /* does the peer prefer encrypted connections? */
     
    16911700
    16921701    peer->minActiveRequests = 4;
    1693     peer->maxActiveRequests = peer->minActiveRequests +
    1694                               estimatedBlocksInNext30Seconds;
     1702    peer->maxActiveRequests = peer->minActiveRequests + estimatedBlocksInNext30Seconds;
    16951703    return TRUE;
    16961704}
     
    17481756            msgs->outMessagesBatchedAt = now;
    17491757        }
    1750         else if( haveMessages
    1751                && ( ( now - msgs->outMessagesBatchedAt ) >
    1752                    msgs->outMessagesBatchPeriod ) )
     1758        else if( ( haveMessages ) &&
     1759                 ( ( now - msgs->outMessagesBatchedAt ) > msgs->outMessagesBatchPeriod ) )
    17531760        {
    1754             dbgmsg( msgs, "flushing outMessages... (length is %zu)", EVBUFFER_LENGTH( msgs->outMessages ) );
     1761            dbgmsg( msgs, "flushing outMessages... to %p (length is %zu)", msgs->io, EVBUFFER_LENGTH( msgs->outMessages ) );
    17551762            tr_peerIoWriteBuf( msgs->io, msgs->outMessages, FALSE );
    17561763            msgs->clientSentAnythingAt = now;
     
    20152022        tr_peerIoWriteBytes ( msgs->io, out, benc, bencLen );
    20162023        pokeBatchPeriod( msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS );
    2017         dbgmsg( msgs, "outMessage size is now %d",
    2018                (int)EVBUFFER_LENGTH( out ) );
     2024        dbgmsg( msgs, "sending a pex message; outMessage size is now %zu", EVBUFFER_LENGTH( out ) );
    20192025
    20202026        /* cleanup */
  • trunk/libtransmission/ptrarray.h

    r6953 r7136  
    3737tr_ptrArray * tr_ptrArrayDup( tr_ptrArray* );
    3838
    39 void          tr_ptrArrayForeach(
    40                         tr_ptrArray*,
    41     PtrArrayForeachFunc func );
     39void          tr_ptrArrayForeach( tr_ptrArray         * array,
     40                                  PtrArrayForeachFunc   func );
    4241
    4342void          tr_ptrArrayFree( tr_ptrArray         * array,
  • trunk/libtransmission/transmission.h

    r7113 r7136  
    4545#ifndef PRIu64
    4646 #define PRIu64 "llu"
     47#endif
     48#ifndef PRIu32
     49 #define PRIu32 "lu"
    4750#endif
    4851#include <time.h> /* time_t */
Note: See TracChangeset for help on using the changeset viewer.