Changeset 3872 for trunk/libtransmission/peer-msgs.c
- Timestamp:
- Nov 18, 2007, 4:24:17 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-msgs.c
r3871 r3872 1441 1441 **/ 1442 1442 1443 static int1444 canWrite( const tr_peermsgs * msgs )1445 {1446 /* don't let our outbuffer get too large */1447 return tr_peerIoWriteBytesWaiting( msgs->io ) < 4096;1448 }1449 1450 1443 static size_t 1451 1444 getUploadMax( const tr_peermsgs * msgs ) … … 1454 1447 const tr_torrent * tor = msgs->torrent; 1455 1448 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; 1461 1453 1462 1454 if( tor->uploadLimitMode == TR_SPEEDLIMIT_GLOBAL ) 1463 speed Bytes= tor->handle->useUploadLimit ? tr_rcBytesLeft( tor->handle->upload ) : maxval;1455 speedLeft = tor->handle->useUploadLimit ? tr_rcBytesLeft( tor->handle->upload ) : maxval; 1464 1456 else if( tor->uploadLimitMode == TR_SPEEDLIMIT_SINGLE ) 1465 speed Bytes= tr_rcBytesLeft( tor->upload );1457 speedLeft = tr_rcBytesLeft( tor->upload ); 1466 1458 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; 1471 1466 } 1472 1467 … … 1526 1521 tr_peermsgs * msgs = vmsgs; 1527 1522 struct peer_request * r; 1528 size_t len;1529 1523 1530 1524 tr_peerIoTryRead( msgs->io ); … … 1540 1534 assert( len ); 1541 1535 1542 if( outlen && canWrite( msgs ))1536 if( outlen ) 1543 1537 { 1544 1538 tr_peerIoWrite( msgs->io, EVBUFFER_DATA( msgs->outBlock ), outlen ); … … 1552 1546 dbgmsg( msgs, "wrote %d bytes; %d left in block", (int)outlen, (int)len ); 1553 1547 } 1548 else dbgmsg( msgs, "stalled writing block... uploadMax %lu, outlen %lu", uploadMax, outlen ); 1554 1549 } 1555 1550 1556 1551 if( !msgs->sendingBlock ) 1557 1552 { 1558 if(( len =EVBUFFER_LENGTH( msgs->outMessages ) ))1553 if(( EVBUFFER_LENGTH( msgs->outMessages ) )) 1559 1554 { 1555 dbgmsg( msgs, "flushing outMessages..." ); 1560 1556 tr_peerIoWriteBuf( msgs->io, msgs->outMessages ); 1561 1557 msgs->clientSentAnythingAt = now;
Note: See TracChangeset
for help on using the changeset viewer.