Changeset 6964
- Timestamp:
- Oct 27, 2008, 4:12:42 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-msgs.c
r6954 r6964 598 598 int choke ) 599 599 { 600 const time_t fibrillationTime = time( NULL ) - MIN_CHOKE_PERIOD_SEC; 600 const time_t now = time( NULL ); 601 const time_t fibrillationTime = now - MIN_CHOKE_PERIOD_SEC; 601 602 602 603 assert( msgs ); … … 615 616 cancelAllRequestsToClientExceptFast( msgs ); 616 617 protocolSendChoke( msgs, choke ); 617 msgs->info->chokeChangedAt = time( NULL );618 msgs->info->chokeChangedAt = now; 618 619 } 619 620 } … … 768 769 769 770 static void 770 expireOldRequests( tr_peermsgs * msgs )771 expireOldRequests( tr_peermsgs * msgs, const time_t now ) 771 772 { 772 773 int i; … … 775 776 776 777 /* cancel requests that have been queued for too long */ 777 oldestAllowed = time( NULL )- QUEUED_REQUEST_TTL_SECS;778 oldestAllowed = now - QUEUED_REQUEST_TTL_SECS; 778 779 reqListCopy( &tmp, &msgs->clientWillAskFor ); 779 780 for( i = 0; i < tmp.count; ++i ) … … 786 787 787 788 /* cancel requests that were sent too long ago */ 788 oldestAllowed = time( NULL )- SENT_REQUEST_TTL_SECS;789 oldestAllowed = now - SENT_REQUEST_TTL_SECS; 789 790 reqListCopy( &tmp, &msgs->clientAskedFor ); 790 791 for( i = 0; i < tmp.count; ++i ) … … 798 799 799 800 static void 800 pumpRequestQueue( tr_peermsgs * msgs )801 pumpRequestQueue( tr_peermsgs * msgs, const time_t now ) 801 802 { 802 803 const int max = msgs->maxActiveRequests; 803 804 const int min = msgs->minActiveRequests; 804 const time_t now = time( NULL );805 805 int sent = 0; 806 806 int count = msgs->clientAskedFor.count; … … 1536 1536 static void 1537 1537 peerGotBytes( tr_peermsgs * msgs, 1538 uint32_t byteCount ) 1539 { 1540 msgs->info->pieceDataActivityDate = time( NULL ); 1538 uint32_t byteCount, 1539 const time_t now ) 1540 { 1541 msgs->info->pieceDataActivityDate = now; 1541 1542 firePeerGotData( msgs, byteCount ); 1542 1543 } … … 1707 1708 1708 1709 /*tr_peerIoTryRead( msgs->io );*/ 1709 pumpRequestQueue( msgs );1710 expireOldRequests( msgs );1710 pumpRequestQueue( msgs, now ); 1711 expireOldRequests( msgs, now ); 1711 1712 1712 1713 if( msgs->sendingBlock ) … … 1720 1721 if( outlen ) 1721 1722 { 1722 tr_peerIoWrite( msgs->io, EVBUFFER_DATA( 1723 msgs->outBlock ), outlen ); 1723 tr_peerIoWrite( msgs->io, EVBUFFER_DATA( msgs->outBlock ), outlen ); 1724 1724 evbuffer_drain( msgs->outBlock, outlen ); 1725 peerGotBytes( msgs, outlen );1725 peerGotBytes( msgs, outlen, now ); 1726 1726 1727 1727 len -= outlen; … … 1734 1734 else dbgmsg( msgs, 1735 1735 "stalled writing block... uploadMax %lu, outlen %lu", 1736 uploadMax, 1737 outlen ); 1736 uploadMax, outlen ); 1738 1737 } 1739 1738 … … 1741 1740 { 1742 1741 struct peer_request req; 1743 int haveMessages = EVBUFFER_LENGTH( 1744 msgs->outMessages ) != 0; 1742 const int haveMessages = EVBUFFER_LENGTH( msgs->outMessages ) != 0; 1745 1743 1746 1744 if( haveMessages && !msgs->outMessagesBatchedAt ) /* fresh batch */
Note: See TracChangeset
for help on using the changeset viewer.