Changeset 7474


Ignore:
Timestamp:
Dec 23, 2008, 5:11:31 PM (12 years ago)
Author:
charles
Message:

(trunk libT) socket performance tweak by wereHamster

File:
1 edited

Legend:

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

    r7469 r7474  
    215215    int res;
    216216    tr_peerIo * io = vio;
    217     const size_t howmuch = tr_bandwidthClamp( io->bandwidth, TR_DOWN, io->session->so_rcvbuf );
     217
     218    /* Limit the input buffer to 256K, so it doesn't grow too large */
     219    const size_t canread = 256 * 1024 - EVBUFFER_LENGTH( io->inbuf );
     220    const size_t howmuch = tr_bandwidthClamp( io->bandwidth, TR_DOWN, canread );
    218221    const tr_direction dir = TR_DOWN;
    219222
     
    291294    dbgmsg( io, "libevent says this peer is ready to write" );
    292295
    293     howmuch = MIN( (size_t)io->session->so_sndbuf, EVBUFFER_LENGTH( io->outbuf ) );
    294     howmuch = tr_bandwidthClamp( io->bandwidth, dir, howmuch );
     296    /* Write as much as possible, since the socket is non-blocking, write() will
     297     * return if it can't write any more data without blocking */
     298    howmuch = tr_bandwidthClamp( io->bandwidth, dir, EVBUFFER_LENGTH( io->outbuf ) );
    295299
    296300    /* if we don't have any bandwidth left, stop writing */
Note: See TracChangeset for help on using the changeset viewer.