Ignore:
Timestamp:
Nov 18, 2007, 4:24:17 AM (15 years ago)
Author:
charles
Message:

more download speed tweaks for situations where T is both uploading and downloading.

File:
1 edited

Legend:

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

    r3871 r3872  
    14411441**/
    14421442
    1443 static int
    1444 canWrite( const tr_peermsgs * msgs )
    1445 {
    1446     /* don't let our outbuffer get too large */
    1447     return tr_peerIoWriteBytesWaiting( msgs->io ) < 4096;
    1448 }
    1449 
    14501443static size_t
    14511444getUploadMax( const tr_peermsgs * msgs )
     
    14541447    const tr_torrent * tor = msgs->torrent;
    14551448    const int useSwift = SWIFT_ENABLED && !tr_torrentIsSeed( msgs->torrent );
    1456     const size_t swiftBytes = msgs->info->credit;
    1457     size_t speedBytes;
    1458 
    1459     if( !canWrite( msgs ) )
    1460         return 0;
     1449    const size_t swiftLeft = msgs->info->credit;
     1450    size_t speedLeft;
     1451    size_t bufLeft;
     1452    size_t ret;
    14611453
    14621454    if( tor->uploadLimitMode == TR_SPEEDLIMIT_GLOBAL )
    1463         speedBytes = tor->handle->useUploadLimit ? tr_rcBytesLeft( tor->handle->upload ) : maxval;
     1455        speedLeft = tor->handle->useUploadLimit ? tr_rcBytesLeft( tor->handle->upload ) : maxval;
    14641456    else if( tor->uploadLimitMode == TR_SPEEDLIMIT_SINGLE )
    1465         speedBytes = tr_rcBytesLeft( tor->upload );
     1457        speedLeft = tr_rcBytesLeft( tor->upload );
    14661458    else
    1467         speedBytes = ~0;
    1468 
    1469     return useSwift ? MIN( speedBytes, swiftBytes )
    1470                     : speedBytes;
     1459        speedLeft = ~0;
     1460
     1461    bufLeft = 4096 - tr_peerIoWriteBytesWaiting( msgs->io );
     1462    ret = MIN( speedLeft, bufLeft );
     1463    if( useSwift)
     1464        ret = MIN( ret, swiftLeft );
     1465    return ret;
    14711466}
    14721467
     
    15261521    tr_peermsgs * msgs = vmsgs;
    15271522    struct peer_request * r;
    1528     size_t len;
    15291523
    15301524    tr_peerIoTryRead( msgs->io );
     
    15401534        assert( len );
    15411535
    1542         if( outlen && canWrite( msgs ) )
     1536        if( outlen )
    15431537        {
    15441538            tr_peerIoWrite( msgs->io, EVBUFFER_DATA( msgs->outBlock ), outlen );
     
    15521546            dbgmsg( msgs, "wrote %d bytes; %d left in block", (int)outlen, (int)len );
    15531547        }
     1548        else dbgmsg( msgs, "stalled writing block... uploadMax %lu, outlen %lu", uploadMax, outlen );
    15541549    }
    15551550
    15561551    if( !msgs->sendingBlock )
    15571552    {
    1558         if(( len = EVBUFFER_LENGTH( msgs->outMessages ) ))
     1553        if(( EVBUFFER_LENGTH( msgs->outMessages ) ))
    15591554        {
     1555            dbgmsg( msgs, "flushing outMessages..." );
    15601556            tr_peerIoWriteBuf( msgs->io, msgs->outMessages );
    15611557            msgs->clientSentAnythingAt = now;
Note: See TracChangeset for help on using the changeset viewer.