Changeset 12074
- Timestamp:
- Mar 3, 2011, 6:33:24 PM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/Makefile.am
r12003 r12074 47 47 port-forwarding.c \ 48 48 ptrarray.c \ 49 ratecontrol.c \50 49 resume.c \ 51 50 rpcimpl.c \ … … 100 99 port-forwarding.h \ 101 100 ptrarray.h \ 102 ratecontrol.h \103 101 resume.h \ 104 102 rpcimpl.h \ -
trunk/libtransmission/bandwidth.h
r11709 r12074 17 17 #ifndef TR_BANDWIDTH_H 18 18 #define TR_BANDWIDTH_H 19 20 #include <assert.h> 19 21 20 22 #include "transmission.h" -
trunk/libtransmission/peer-mgr.c
r12073 r12074 379 379 } 380 380 381 static tr_peer* 382 peerNew( struct peer_atom * atom)383 { 384 tr_peer * peer = tr_new0( tr_peer, 1);381 void 382 tr_peerConstruct( tr_peer * peer ) 383 { 384 memset( peer, 0, sizeof( tr_peer ) ); 385 385 386 386 peer->have = TR_BITSET_INIT; 387 388 peer->atom = atom;389 atom->peer = peer;390 387 391 388 tr_historyConstruct( &peer->blocksSentToClient, CANCEL_HISTORY_SEC, ( RECHOKE_PERIOD_MSEC / 1000 ) ); … … 393 390 tr_historyConstruct( &peer->cancelsSentToClient, CANCEL_HISTORY_SEC, ( RECHOKE_PERIOD_MSEC / 1000 ) ); 394 391 tr_historyConstruct( &peer->cancelsSentToPeer, CANCEL_HISTORY_SEC, ( REFILL_UPKEEP_PERIOD_MSEC / 1000 ) ); 392 } 393 394 static tr_peer* 395 peerNew( struct peer_atom * atom ) 396 { 397 tr_peer * peer = tr_new( tr_peer, 1 ); 398 tr_peerConstruct( peer ); 399 400 peer->atom = atom; 401 atom->peer = peer; 395 402 396 403 return peer; … … 417 424 static void peerDeclinedAllRequests( Torrent *, const tr_peer * ); 418 425 419 staticvoid420 peerDelete( Torrent * t, tr_peer * peer )426 void 427 tr_peerDestruct( tr_torrent * tor, tr_peer * peer ) 421 428 { 422 429 assert( peer != NULL ); 423 430 424 peerDeclinedAllRequests( t , peer );431 peerDeclinedAllRequests( tor->torrentPeers, peer ); 425 432 426 433 if( peer->msgs != NULL ) 427 434 tr_peerMsgsFree( peer->msgs ); 428 435 429 tr_peerIoClear( peer->io ); 430 tr_peerIoUnref( peer->io ); /* balanced by the ref in handshakeDoneCB() */ 436 if( peer->io ) { 437 tr_peerIoClear( peer->io ); 438 tr_peerIoUnref( peer->io ); /* balanced by the ref in handshakeDoneCB() */ 439 } 431 440 432 441 tr_historyDestruct( &peer->blocksSentToClient ); … … 439 448 tr_free( peer->client ); 440 449 peer->atom->peer = NULL; 441 450 } 451 452 static void 453 peerDelete( Torrent * t, tr_peer * peer ) 454 { 455 tr_peerDestruct( t->tor, peer ); 442 456 tr_free( peer ); 443 457 } … … 2458 2472 } 2459 2473 2460 if( peer-> progress >= 1.0)2474 if( peer->atom && ( peer->progress >= 1.0 ) ) 2461 2475 atomSetSeed( tor->torrentPeers, peer->atom ); 2462 2476 } … … 2580 2594 *setmeWebseedsSendingToUs = countActiveWebseeds( t ); 2581 2595 } 2582 2583 int2584 tr_peerMgrGetWebseedSpeed_Bps( const tr_torrent * tor, uint64_t now )2585 {2586 int i;2587 int tmp;2588 int ret = 0;2589 2590 const Torrent * t = tor->torrentPeers;2591 const int n = tr_ptrArraySize( &t->webseeds );2592 const tr_webseed ** webseeds = (const tr_webseed**) tr_ptrArrayBase( &t->webseeds );2593 2594 for( i=0; i<n; ++i )2595 if( tr_webseedGetSpeed_Bps( webseeds[i], now, &tmp ) )2596 ret += tmp;2597 2598 return ret;2599 }2600 2601 2596 2602 2597 double* -
trunk/libtransmission/peer-mgr.h
r12022 r12074 69 69 70 70 71 struct tr_bandwidth;72 71 struct tr_peerIo; 73 72 struct tr_peermsgs; … … 132 131 } 133 132 tr_peer; 133 134 void tr_peerConstruct( struct tr_peer * peer ); 135 136 void tr_peerDestruct( tr_torrent * tor, struct tr_peer * peer ); 137 134 138 135 139 static inline tr_bool … … 248 252 int * setmeCount ); 249 253 250 int tr_peerMgrGetWebseedSpeed_Bps( const tr_torrent * tor, uint64_t now );251 252 254 double* tr_peerMgrWebSpeeds_KBps( const tr_torrent * tor ); 253 255 -
trunk/libtransmission/torrent.c
r12057 r12074 1139 1139 int usableSeeds; 1140 1140 uint64_t now; 1141 double d;1142 1141 uint64_t seedRatioBytesLeft; 1143 1142 uint64_t seedRatioBytesGoal; … … 1171 1170 1172 1171 now = tr_time_msec( ); 1173 d = tr_peerMgrGetWebseedSpeed_Bps( tor, now );1174 1172 s->rawUploadSpeed_KBps = toSpeedKBps( tr_bandwidthGetRawSpeed_Bps ( tor->bandwidth, now, TR_UP ) ); 1175 1173 s->pieceUploadSpeed_KBps = toSpeedKBps( tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_UP ) ); 1176 s->rawDownloadSpeed_KBps = toSpeedKBps( d +tr_bandwidthGetRawSpeed_Bps ( tor->bandwidth, now, TR_DOWN ) );1177 s->pieceDownloadSpeed_KBps = toSpeedKBps( d +tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_DOWN ) );1174 s->rawDownloadSpeed_KBps = toSpeedKBps( tr_bandwidthGetRawSpeed_Bps ( tor->bandwidth, now, TR_DOWN ) ); 1175 s->pieceDownloadSpeed_KBps = toSpeedKBps( tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_DOWN ) ); 1178 1176 1179 1177 usableSeeds += tor->info.webseedCount; -
trunk/libtransmission/webseed.c
r12012 r12074 17 17 18 18 #include "transmission.h" 19 #include "bandwidth.h" 19 20 #include "cache.h" 20 21 #include "inout.h" /* tr_ioFindFileLocation() */ 21 22 #include "list.h" 22 #include "ratecontrol.h"23 23 #include "peer-mgr.h" 24 24 #include "torrent.h" … … 42 42 { 43 43 tr_peer parent; 44 tr_ ratecontrol download_rate;44 tr_bandwidth bandwidth; 45 45 tr_session * session; 46 46 tr_peer_callback * callback; … … 65 65 webseed_free( struct tr_webseed * w ) 66 66 { 67 tr_ bitsetDestruct( &w->parent.have);68 tr_free( w->parent.client ); 69 67 tr_torrent * tor = tr_torrentFindFromId( w->session, w->torrent_id ); 68 69 /* webseed destruct */ 70 70 event_free( w->timer ); 71 tr_ rcDestruct( &w->download_rate);71 tr_bandwidthDestruct( &w->bandwidth ); 72 72 tr_free( w->base_url ); 73 74 /* parent class destruct */ 75 tr_peerDestruct( tor, &w->parent ); 76 73 77 tr_free( w ); 74 78 } … … 126 130 if( ( info->n_added > 0 ) && !w->is_stopping ) 127 131 { 128 tr_ rcTransferred( &w->download_rate, info->n_added);132 tr_bandwidthUsed( &w->bandwidth, TR_DOWN, info->n_added, TRUE, tr_time_msec( ) ); 129 133 fire_client_got_data( w, info->n_added ); 130 134 } … … 297 301 { 298 302 const tr_bool is_active = webseed_has_tasks( w ); 299 *setme_Bps = is_active ? tr_ rcRate_Bps( &w->download_rate, now) : 0;303 *setme_Bps = is_active ? tr_bandwidthGetPieceSpeed_Bps( &w->bandwidth, now, TR_DOWN ) : 0; 300 304 return is_active; 301 305 } … … 321 325 322 326 tr_webseed* 323 tr_webseedNew( struct tr_torrent * tor,324 const char * url,325 tr_peer_callback * callback,326 void * callback_data )327 tr_webseedNew( struct tr_torrent * tor, 328 const char * url, 329 tr_peer_callback * callback, 330 void * callback_data ) 327 331 { 328 332 tr_webseed * w = tr_new0( tr_webseed, 1 ); 329 333 tr_peer * peer = &w->parent; 330 334 335 /* construct parent class */ 336 tr_peerConstruct( peer ); 331 337 peer->peerIsChoked = TRUE; 332 338 peer->clientIsInterested = !tr_torrentIsSeed( tor ); 333 peer->progress = 1.0;334 339 peer->client = tr_strdup( "webseed" ); 335 peer->have = TR_BITSET_INIT;336 340 tr_bitsetSetHaveAll( &peer->have ); 341 tr_peerUpdateProgress( tor, peer ); 337 342 338 343 w->torrent_id = tr_torrentId( tor ); 339 344 w->session = tor->session; 340 341 345 w->base_url_len = strlen( url ); 342 346 w->base_url = tr_strndup( url, w->base_url_len ); 343 347 w->callback = callback; 344 348 w->callback_data = callback_data; 345 tr_rcConstruct( &w->download_rate ); 349 //tr_rcConstruct( &w->download_rate ); 350 tr_bandwidthConstruct( &w->bandwidth, tor->session, tor->bandwidth ); 346 351 w->timer = evtimer_new( w->session->event_base, webseed_timer_func, w ); 347 352 tr_timerAddMsec( w->timer, TR_IDLE_TIMER_MSEC );
Note: See TracChangeset
for help on using the changeset viewer.