1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-15 16:29:34 +00:00

Force rates to 0 when paused, and download rate to 0 when seeding.

Increased OS X UI update interval to 1 second.
This commit is contained in:
Eric Petit 2006-02-07 02:32:50 +00:00
parent fa3e10b2c0
commit fcd1c9a1a8
4 changed files with 38 additions and 6 deletions

View file

@ -144,15 +144,25 @@ float tr_rcRate( tr_ratecontrol_t * r )
return ret;
}
void tr_rcClose( tr_ratecontrol_t * r )
void tr_rcReset( tr_ratecontrol_t * r )
{
tr_transfer_t * t, * next;
tr_lockLock( &r->lock );
for( t = r->first; t; )
{
next = t->next;
free( t );
t = next;
}
r->first = NULL;
r->last = NULL;
tr_lockUnlock( &r->lock );
}
void tr_rcClose( tr_ratecontrol_t * r )
{
tr_rcReset( r );
tr_lockClose( &r->lock );
free( r );
}

View file

@ -27,4 +27,5 @@ void tr_rcSetLimit( tr_ratecontrol_t *, int );
int tr_rcCanTransfer( tr_ratecontrol_t * );
void tr_rcTransferred( tr_ratecontrol_t *, int );
float tr_rcRate( tr_ratecontrol_t * );
void tr_rcReset( tr_ratecontrol_t * );
void tr_rcClose( tr_ratecontrol_t * );

View file

@ -156,8 +156,20 @@ void tr_setUploadLimit( tr_handle_t * h, int limit )
**********************************************************************/
void tr_torrentRates( tr_handle_t * h, float * dl, float * ul )
{
*dl = tr_rcRate( h->download );
*ul = tr_rcRate( h->upload );
tr_torrent_t * tor;
int i;
*dl = 0.0;
*ul = 0.0;
for( i = 0; i < h->torrentCount; i++ )
{
tor = h->torrents[i];
tr_lockLock( &tor->lock );
if( tor->status & TR_STATUS_DOWNLOAD )
*dl += tr_rcRate( tor->download );
*ul += tr_rcRate( tor->upload );
tr_lockUnlock( &tor->lock );
}
}
/***********************************************************************
@ -301,6 +313,8 @@ void tr_torrentStop( tr_handle_t * h, int t )
tr_lockLock( &tor->lock );
tr_trackerStopped( tor->tracker );
tr_rcReset( tor->download );
tr_rcReset( tor->upload );
tor->status = TR_STATUS_STOPPING;
tor->stopDate = tr_date();
tr_lockUnlock( &tor->lock );
@ -404,8 +418,15 @@ int tr_torrentStat( tr_handle_t * h, tr_stat_t ** stat )
}
s[i].progress = tr_cpCompletionAsFloat( tor->completion );
s[i].rateDownload = tr_rcRate( tor->download );
s[i].rateUpload = tr_rcRate( tor->upload );
if( tor->status & TR_STATUS_DOWNLOAD )
s[i].rateDownload = tr_rcRate( tor->download );
else
/* tr_rcRate() doesn't make the difference between 'piece'
messages and other messages, which causes a non-zero
download rate even tough we are not downloading. So we
force it to zero not to confuse the user. */
s[i].rateDownload = 0.0;
s[i].rateUpload = tr_rcRate( tor->upload );
s[i].seeders = tr_trackerSeeders(tor);
s[i].leechers = tr_trackerLeechers(tor);

View file

@ -144,7 +144,7 @@ static void sleepCallBack( void * controller, io_service_t y,
fSeeding = 0;
fCompleted = 0;
fStat = nil;
fTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5 target: self
fTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self
selector: @selector( updateUI: ) userInfo: NULL repeats: YES];
[[NSRunLoop currentRunLoop] addTimer: fTimer
forMode: NSModalPanelRunLoopMode];