Changeset 2234
- Timestamp:
- Jun 29, 2007, 5:24:14 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer.c
r2233 r2234 851 851 tr_torrentSwiftPulse ( tr_torrent_t * tor ) 852 852 { 853 /* Preferred # of seconds for the request queue's turnaround time. 854 This is just an arbitrary number. */ 855 const int queueTimeSec = 5; 856 const int blockSizeKiB = tor->blockSize / 1024; 857 int deadbeatCount = 0; 853 858 int i; 854 int deadbeatCount = 0;855 859 tr_peer_t ** deadbeats; 856 860 … … 859 863 for( i=0; i<tor->peerCount; ++i ) 860 864 { 861 /* preferred # of seconds for the request queue's turnaround time. 862 this is just an arbitrary number. */ 863 const int queueTime = 5; 864 int j; 865 double outboundSpeedKiBs; 866 double inboundSpeedKiBs; 867 int j, size; 865 868 tr_peer_t * peer = tor->peers[ i ]; 866 869 … … 868 871 continue; 869 872 870 /* decide how deep the request queue should be */ 871 peer->outRequestMax = queueTime * tr_rcRate(peer->download) / tor->blockSize; 872 peer->inRequestMax += 2; /* room to grow */ 873 874 /* make room for new requests */ 873 /* decide how many blocks we'll concurrently ask this peer for */ 874 outboundSpeedKiBs = tr_rcRate(peer->upload); 875 size = queueTimeSec * outboundSpeedKiBs / blockSizeKiB; 876 if( size < 4 ) /* don't let it get TOO small */ 877 size = 4; 878 size += 4; /* and always leave room to grow */ 879 peer->inRequestMax = size; 880 if( peer->inRequestAlloc < peer->inRequestMax ) { 881 peer->inRequestAlloc = peer->inRequestMax; 882 peer->inRequests = tr_renew( tr_request_t, peer->inRequests, peer->inRequestAlloc ); 883 } 884 885 /* decide how many blocks we'll concurrently let the peer ask us for */ 886 inboundSpeedKiBs = tr_rcRate(peer->download); 887 size = queueTimeSec * inboundSpeedKiBs / blockSizeKiB; 888 if( size < 4 ) /* don't let it get TOO small */ 889 size = 4; 890 size += 4; /* and always leave room to grow */ 891 peer->outRequestMax = size; 875 892 if( peer->outRequestAlloc < peer->outRequestMax ) { 876 893 peer->outRequestAlloc = peer->outRequestMax; 877 894 peer->outRequests = tr_renew( tr_request_t, peer->outRequests, peer->outRequestAlloc ); 878 895 } 879 880 /* decide how deep the request queue should be */ 881 peer->inRequestMax = queueTime * tr_rcRate(peer->download) / (tor->blockSize/1024); 882 peer->inRequestMax += 2; /* room to grow */ 883 884 /* make room for new requests */ 885 if( peer->inRequestAlloc < peer->inRequestMax ) { 886 peer->inRequestAlloc = peer->inRequestMax; 887 peer->inRequests = tr_renew( tr_request_t, peer->inRequests, peer->inRequestAlloc ); 888 } 889 890 /* queue shrank... notify completion that we won't be sending those requests */ 891 for( j=peer->inRequestMax; j<peer->inRequestCount; ++j ) { 892 tr_request_t * r = &peer->inRequests[j]; 893 tr_cpDownloaderRem( tor->completion, tr_block(r->index,r->begin) ); 894 } 895 } 896 897 deadbeats = tr_calloc( tor->peerCount, sizeof(tr_peer_t*) ); 896 } 897 898 deadbeats = g_new( tr_peer_t*, tor->peerCount ); 899 deadbeatCount = 0; 898 900 for( i=0; i<tor->peerCount; ++i ) { 899 901 tr_peer_t * peer = tor->peers[ i ]; … … 919 921 } 920 922 921 free( deadbeats );923 tr_free( deadbeats ); 922 924 923 925 tr_torrentWriterUnlock( tor );
Note: See TracChangeset
for help on using the changeset viewer.