Changeset 7154 for trunk/libtransmission/torrent.c
- Timestamp:
- Nov 25, 2008, 9:35:17 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/torrent.c
r7147 r7154 144 144 void 145 145 tr_torrentSetSpeedMode( tr_torrent * tor, 146 tr_direction dir ection,146 tr_direction dir, 147 147 tr_speedlimit mode ) 148 148 { 149 tr_speedlimit * limit = direction == TR_UP ? &tor->uploadLimitMode 150 : &tor->downloadLimitMode; 151 152 *limit = mode; 149 assert( tor != NULL ); 150 assert( dir==TR_UP || dir==TR_DOWN ); 151 assert( mode==TR_SPEEDLIMIT_GLOBAL || mode==TR_SPEEDLIMIT_SINGLE || mode==TR_SPEEDLIMIT_UNLIMITED ); 152 153 tor->speedLimitMode[dir] = mode; 154 155 tr_bandwidthSetLimited( tor->bandwidth, dir, mode==TR_SPEEDLIMIT_SINGLE ); 156 tr_bandwidthHonorParentLimits( tor->bandwidth, dir, mode!=TR_SPEEDLIMIT_UNLIMITED ); 153 157 } 154 158 155 159 tr_speedlimit 156 160 tr_torrentGetSpeedMode( const tr_torrent * tor, 157 tr_direction direction ) 158 { 159 return direction == TR_UP ? tor->uploadLimitMode 160 : tor->downloadLimitMode; 161 tr_direction dir ) 162 { 163 assert( tor != NULL ); 164 assert( dir==TR_UP || dir==TR_DOWN ); 165 166 return tor->speedLimitMode[dir]; 161 167 } 162 168 163 169 void 164 170 tr_torrentSetSpeedLimit( tr_torrent * tor, 165 tr_direction direction, 166 int single_KiB_sec ) 167 { 168 switch( direction ) 169 { 170 case TR_UP: 171 tor->uploadLimit = single_KiB_sec; break; 172 173 case TR_DOWN: 174 tor->downloadLimit = single_KiB_sec; break; 175 176 default: 177 assert( 0 ); 178 } 171 tr_direction dir, 172 int desiredSpeed ) 173 { 174 tr_bandwidthSetDesiredSpeed( tor->bandwidth, dir, desiredSpeed ); 179 175 } 180 176 181 177 int 182 178 tr_torrentGetSpeedLimit( const tr_torrent * tor, 183 tr_direction direction ) 184 { 185 switch( direction ) 186 { 187 case TR_UP: 188 return tor->uploadLimit; 189 190 case TR_DOWN: 191 return tor->downloadLimit; 192 193 default: 194 assert( 0 ); 195 } 179 tr_direction dir ) 180 { 181 return tr_bandwidthGetDesiredSpeed( tor->bandwidth, dir ); 196 182 } 197 183 … … 498 484 randomizeTiers( info ); 499 485 500 tor->bandwidth[TR_UP] = tr_bandwidthNew( h ); 501 tor->bandwidth[TR_DOWN] = tr_bandwidthNew( h ); 486 tor->bandwidth = tr_bandwidthNew( h, h->bandwidth ); 487 488 fprintf( stderr, "torrent [%s] bandwidth is %p\n", info->name, tor->bandwidth ); 502 489 503 490 tor->blockSize = getBlockSize( info->pieceSize ); … … 541 528 tr_torrentInitFilePieces( tor ); 542 529 543 tor->uploadLimit = 0;544 tor->downloadLimit = 0;545 530 tor->swarmSpeed = tr_rcInit( ); 546 531 … … 814 799 s->peersFrom ); 815 800 816 s->rawUploadSpeed = tr_bandwidthGetRawSpeed ( tor->bandwidth [TR_UP]);817 s->rawDownloadSpeed = tr_bandwidthGetRawSpeed ( tor->bandwidth [TR_DOWN]);818 s->pieceUploadSpeed = tr_bandwidthGetPieceSpeed( tor->bandwidth [TR_UP]);819 s->pieceDownloadSpeed = tr_bandwidthGetPieceSpeed( tor->bandwidth [TR_DOWN]);801 s->rawUploadSpeed = tr_bandwidthGetRawSpeed ( tor->bandwidth, TR_UP ); 802 s->rawDownloadSpeed = tr_bandwidthGetRawSpeed ( tor->bandwidth, TR_DOWN ); 803 s->pieceUploadSpeed = tr_bandwidthGetPieceSpeed( tor->bandwidth, TR_UP ); 804 s->pieceDownloadSpeed = tr_bandwidthGetPieceSpeed( tor->bandwidth, TR_DOWN ); 820 805 821 806 usableSeeds += tor->info.webseedCount; … … 1100 1085 h->torrentCount--; 1101 1086 1102 tr_bandwidthFree( tor->bandwidth[TR_DOWN] ); 1103 tr_bandwidthFree( tor->bandwidth[TR_UP] ); 1087 tr_bandwidthFree( tor->bandwidth ); 1104 1088 1105 1089 tr_metainfoFree( inf );
Note: See TracChangeset
for help on using the changeset viewer.