mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
minor tweaks.
This commit is contained in:
parent
94b60cd89e
commit
6242508fe2
5 changed files with 27 additions and 29 deletions
|
@ -48,6 +48,21 @@ struct tr_completion
|
||||||
uint64_t completeHave;
|
uint64_t completeHave;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
tr_cpReset( tr_completion * cp )
|
||||||
|
{
|
||||||
|
tr_torrent * tor = cp->tor;
|
||||||
|
|
||||||
|
tr_bitfieldClear( cp->pieceBitfield );
|
||||||
|
tr_bitfieldClear( cp->blockBitfield );
|
||||||
|
memset( cp->completeBlocks, 0, sizeof(uint16_t) * tor->info.pieceCount );
|
||||||
|
|
||||||
|
cp->doneDirty = TRUE;
|
||||||
|
cp->doneHave = 0;
|
||||||
|
cp->doneTotal = 0;
|
||||||
|
cp->completeHave = 0;
|
||||||
|
}
|
||||||
|
|
||||||
tr_completion * tr_cpInit( tr_torrent * tor )
|
tr_completion * tr_cpInit( tr_torrent * tor )
|
||||||
{
|
{
|
||||||
tr_completion * cp;
|
tr_completion * cp;
|
||||||
|
@ -71,20 +86,6 @@ void tr_cpClose( tr_completion * cp )
|
||||||
tr_free( cp );
|
tr_free( cp );
|
||||||
}
|
}
|
||||||
|
|
||||||
void tr_cpReset( tr_completion * cp )
|
|
||||||
{
|
|
||||||
tr_torrent * tor = cp->tor;
|
|
||||||
|
|
||||||
tr_bitfieldClear( cp->pieceBitfield );
|
|
||||||
tr_bitfieldClear( cp->blockBitfield );
|
|
||||||
memset( cp->completeBlocks, 0, sizeof(uint16_t) * tor->info.pieceCount );
|
|
||||||
|
|
||||||
cp->doneDirty = TRUE;
|
|
||||||
cp->doneHave = 0;
|
|
||||||
cp->doneTotal = 0;
|
|
||||||
cp->completeHave = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
***
|
***
|
||||||
**/
|
**/
|
||||||
|
@ -310,11 +311,11 @@ tr_cpHaveValid( const tr_completion * cp )
|
||||||
if( tr_cpPieceIsComplete( cp, info->pieceCount-1 ) )
|
if( tr_cpPieceIsComplete( cp, info->pieceCount-1 ) )
|
||||||
b -= (info->pieceSize - (info->totalSize % info->pieceSize));
|
b -= (info->pieceSize - (info->totalSize % info->pieceSize));
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
tr_cpHaveTotal( const tr_completion * cp )
|
tr_cpHaveTotal( const tr_completion * cp )
|
||||||
{
|
{
|
||||||
return cp->completeHave;
|
return cp->completeHave;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ typedef struct tr_completion tr_completion;
|
||||||
|
|
||||||
tr_completion * tr_cpInit( tr_torrent * );
|
tr_completion * tr_cpInit( tr_torrent * );
|
||||||
void tr_cpClose( tr_completion * );
|
void tr_cpClose( tr_completion * );
|
||||||
void tr_cpReset( tr_completion * );
|
|
||||||
|
|
||||||
/* General */
|
/* General */
|
||||||
|
|
||||||
|
|
|
@ -788,7 +788,7 @@ fastResumeLoadImpl ( tr_torrent * tor,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we didn't read the data, seek past it */
|
/* if we didn't read the data, seek past it */
|
||||||
tr_inf( "Skipping resume data type %02x, %u bytes", id, len );
|
tr_dbg( "Skipping resume data type %02x, %u bytes", id, len );
|
||||||
fseek( file, len, SEEK_CUR );
|
fseek( file, len, SEEK_CUR );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,11 @@
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h> /* memset */
|
||||||
|
|
||||||
#include "transmission.h"
|
#include "transmission.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "ratecontrol.h"
|
#include "ratecontrol.h"
|
||||||
#include "shared.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#define GRANULARITY_MSEC 250
|
#define GRANULARITY_MSEC 250
|
||||||
|
@ -35,19 +34,18 @@
|
||||||
#define LONG_INTERVAL_MSEC 20000
|
#define LONG_INTERVAL_MSEC 20000
|
||||||
#define HISTORY_SIZE (LONG_INTERVAL_MSEC / GRANULARITY_MSEC)
|
#define HISTORY_SIZE (LONG_INTERVAL_MSEC / GRANULARITY_MSEC)
|
||||||
|
|
||||||
typedef struct
|
struct tr_transfer
|
||||||
{
|
{
|
||||||
uint64_t date;
|
uint64_t date;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
}
|
};
|
||||||
tr_transfer_t;
|
|
||||||
|
|
||||||
struct tr_ratecontrol
|
struct tr_ratecontrol
|
||||||
{
|
{
|
||||||
tr_lock * lock;
|
tr_lock * lock;
|
||||||
int limit;
|
int limit;
|
||||||
int newest;
|
int newest;
|
||||||
tr_transfer_t transfers[HISTORY_SIZE];
|
struct tr_transfer transfers[HISTORY_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* return the xfer rate over the last `interval' seconds in KiB/sec */
|
/* return the xfer rate over the last `interval' seconds in KiB/sec */
|
||||||
|
@ -182,7 +180,7 @@ tr_rcReset( tr_ratecontrol * r )
|
||||||
{
|
{
|
||||||
tr_lockLock( (tr_lock*)r->lock );
|
tr_lockLock( (tr_lock*)r->lock );
|
||||||
r->newest = 0;
|
r->newest = 0;
|
||||||
memset( r->transfers, 0, sizeof(tr_transfer_t) * HISTORY_SIZE );
|
memset( r->transfers, 0, sizeof(struct tr_transfer) * HISTORY_SIZE );
|
||||||
tr_lockUnlock( (tr_lock*)r->lock );
|
tr_lockUnlock( (tr_lock*)r->lock );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,8 @@ tr_upnpStart( tr_upnp * handle )
|
||||||
{
|
{
|
||||||
struct UPNPDev * devlist = upnpDiscover( 2000, NULL );
|
struct UPNPDev * devlist = upnpDiscover( 2000, NULL );
|
||||||
if( UPNP_GetValidIGD( devlist, &handle->urls, &handle->data, handle->lanaddr, sizeof(handle->lanaddr))) {
|
if( UPNP_GetValidIGD( devlist, &handle->urls, &handle->data, handle->lanaddr, sizeof(handle->lanaddr))) {
|
||||||
tr_dbg( "Found Internet Gateway Device '%s'", handle->urls.controlURL );
|
tr_dbg( "UPNP: Found Internet Gateway Device '%s'", handle->urls.controlURL );
|
||||||
tr_dbg( "Local LAN IP Address is '%s'", handle->lanaddr );
|
tr_dbg( "UPNP: Local LAN IP Address is '%s'", handle->lanaddr );
|
||||||
}
|
}
|
||||||
freeUPNPDevlist( devlist );
|
freeUPNPDevlist( devlist );
|
||||||
handle->hasDiscovered = 1;
|
handle->hasDiscovered = 1;
|
||||||
|
@ -84,9 +84,9 @@ tr_upnpStart( tr_upnp * handle )
|
||||||
portStr, portStr, handle->lanaddr,
|
portStr, portStr, handle->lanaddr,
|
||||||
"Transmission", "TCP" ) );
|
"Transmission", "TCP" ) );
|
||||||
|
|
||||||
tr_dbg( "UPNP Port Forwarding via '%s', service '%s'. (local address: %s:%d)",
|
tr_inf( "UPNP: Port Forwarding via '%s', service '%s'. (local address: %s:%d)",
|
||||||
handle->urls.controlURL, handle->data.servicetype, handle->lanaddr, handle->port );
|
handle->urls.controlURL, handle->data.servicetype, handle->lanaddr, handle->port );
|
||||||
tr_dbg( "UPNP Port Forwarding Enabled? %s", (handle->isForwarding?"Yes":"No") );
|
tr_inf( "UPNP: Port Forwarding Enabled? %s", (handle->isForwarding?"Yes":"No") );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue