mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
(trunk libt) rename tr_date() as tr_time_msec() for clarity
This commit is contained in:
@@ -34,7 +34,7 @@ static unsigned int
|
|||||||
getSpeed_Bps( const struct bratecontrol * r, unsigned int interval_msec, uint64_t now )
|
getSpeed_Bps( const struct bratecontrol * r, unsigned int interval_msec, uint64_t now )
|
||||||
{
|
{
|
||||||
uint64_t bytes = 0;
|
uint64_t bytes = 0;
|
||||||
const uint64_t cutoff = (now?now:tr_date()) - interval_msec;
|
const uint64_t cutoff = (now?now:tr_time_msec()) - interval_msec;
|
||||||
int i = r->newest;
|
int i = r->newest;
|
||||||
|
|
||||||
for( ;; )
|
for( ;; )
|
||||||
@@ -381,5 +381,5 @@ tr_bandwidthUsed( tr_bandwidth * b,
|
|||||||
size_t byteCount,
|
size_t byteCount,
|
||||||
tr_bool isPieceData )
|
tr_bool isPieceData )
|
||||||
{
|
{
|
||||||
bandwidthUsedImpl( b, dir, byteCount, isPieceData, tr_date( ) );
|
bandwidthUsedImpl( b, dir, byteCount, isPieceData, tr_time_msec( ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ tr_cryptoWeakRandInt( int upperBound )
|
|||||||
|
|
||||||
if( !init )
|
if( !init )
|
||||||
{
|
{
|
||||||
srand( tr_date( ) );
|
srand( tr_time_msec( ) );
|
||||||
init = TRUE;
|
init = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ tr_fdFileGetCached( tr_session * session,
|
|||||||
|
|
||||||
if( ( match != NULL ) && ( !doWrite || match->isWritable ) )
|
if( ( match != NULL ) && ( !doWrite || match->isWritable ) )
|
||||||
{
|
{
|
||||||
match->date = tr_date( );
|
match->date = tr_time_msec( );
|
||||||
return match->fd;
|
return match->fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,7 +532,7 @@ tr_fdFileCheckout( tr_session * session,
|
|||||||
dbgmsg( "it's not already open. looking for an open slot or an old file." );
|
dbgmsg( "it's not already open. looking for an open slot or an old file." );
|
||||||
while( winner < 0 )
|
while( winner < 0 )
|
||||||
{
|
{
|
||||||
uint64_t date = tr_date( ) + 1;
|
uint64_t date = tr_time_msec( ) + 1;
|
||||||
|
|
||||||
/* look for the file that's been open longest */
|
/* look for the file that's been open longest */
|
||||||
for( i=0; i<gFd->openFileLimit; ++i )
|
for( i=0; i<gFd->openFileLimit; ++i )
|
||||||
@@ -582,7 +582,7 @@ tr_fdFileCheckout( tr_session * session,
|
|||||||
dbgmsg( "checking out '%s' in slot %d", filename, winner );
|
dbgmsg( "checking out '%s' in slot %d", filename, winner );
|
||||||
o->torrentId = torrentId;
|
o->torrentId = torrentId;
|
||||||
o->fileNum = fileNum;
|
o->fileNum = fileNum;
|
||||||
o->date = tr_date( );
|
o->date = tr_time_msec( );
|
||||||
return o->fd;
|
return o->fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ unsigned int
|
|||||||
tr_historyGet( const tr_recentHistory * h, uint64_t now, unsigned int msec )
|
tr_historyGet( const tr_recentHistory * h, uint64_t now, unsigned int msec )
|
||||||
{
|
{
|
||||||
unsigned int n = 0;
|
unsigned int n = 0;
|
||||||
const uint64_t cutoff = (now?now:tr_date()) - msec;
|
const uint64_t cutoff = (now?now:tr_time_msec()) - msec;
|
||||||
int i = h->newest;
|
int i = h->newest;
|
||||||
|
|
||||||
for( ;; )
|
for( ;; )
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ void tr_historyFree( tr_recentHistory * );
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief add a counter to the recent history object.
|
* @brief add a counter to the recent history object.
|
||||||
* @param when the current time in msec, such as from tr_date()
|
* @param when the current time in msec, such as from tr_time_msec()
|
||||||
* @param n how many items to add to the history's counter
|
* @param n how many items to add to the history's counter
|
||||||
*/
|
*/
|
||||||
void tr_historyAdd( tr_recentHistory *, uint64_t when, unsigned int n );
|
void tr_historyAdd( tr_recentHistory *, uint64_t when, unsigned int n );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief count how many events have occurred in the last N seconds.
|
* @brief count how many events have occurred in the last N seconds.
|
||||||
* @param when the current time in msec, such as from tr_date()
|
* @param when the current time in msec, such as from tr_time_msec()
|
||||||
* @param seconds how many seconds to count back through.
|
* @param seconds how many seconds to count back through.
|
||||||
*/
|
*/
|
||||||
unsigned int tr_historyGet( const tr_recentHistory *, uint64_t when, unsigned int seconds );
|
unsigned int tr_historyGet( const tr_recentHistory *, uint64_t when, unsigned int seconds );
|
||||||
|
|||||||
@@ -1183,7 +1183,7 @@ refillUpkeep( int foo UNUSED, short bar UNUSED, void * vmgr )
|
|||||||
managerLock( mgr );
|
managerLock( mgr );
|
||||||
|
|
||||||
now = tr_time( );
|
now = tr_time( );
|
||||||
now_msec = tr_date( );
|
now_msec = tr_time_msec( );
|
||||||
too_old = now - REQUEST_TTL_SECS;
|
too_old = now - REQUEST_TTL_SECS;
|
||||||
|
|
||||||
tor = NULL;
|
tor = NULL;
|
||||||
@@ -1437,7 +1437,7 @@ peerCallbackFunc( tr_peer * peer, const tr_peer_event * e, void * vt )
|
|||||||
pieceListRemoveRequest( t, block );
|
pieceListRemoveRequest( t, block );
|
||||||
|
|
||||||
if( peer != NULL )
|
if( peer != NULL )
|
||||||
tr_historyAdd( peer->blocksSentToClient, tr_date( ), 1 );
|
tr_historyAdd( peer->blocksSentToClient, tr_time_msec( ), 1 );
|
||||||
|
|
||||||
if( tr_cpBlockIsComplete( &tor->completion, block ) )
|
if( tr_cpBlockIsComplete( &tor->completion, block ) )
|
||||||
{
|
{
|
||||||
@@ -2286,7 +2286,7 @@ tr_peerMgrWebSpeeds_KBps( const tr_torrent * tor )
|
|||||||
webseedCount = tr_ptrArraySize( &t->webseeds );
|
webseedCount = tr_ptrArraySize( &t->webseeds );
|
||||||
assert( webseedCount == tor->info.webseedCount );
|
assert( webseedCount == tor->info.webseedCount );
|
||||||
ret = tr_new0( double, webseedCount );
|
ret = tr_new0( double, webseedCount );
|
||||||
now = tr_date( );
|
now = tr_time_msec( );
|
||||||
|
|
||||||
for( i=0; i<webseedCount; ++i ) {
|
for( i=0; i<webseedCount; ++i ) {
|
||||||
int Bps;
|
int Bps;
|
||||||
@@ -2324,7 +2324,7 @@ tr_peerMgrPeerStats( const tr_torrent * tor,
|
|||||||
size = tr_ptrArraySize( &t->peers );
|
size = tr_ptrArraySize( &t->peers );
|
||||||
peers = (const tr_peer**) tr_ptrArrayBase( &t->peers );
|
peers = (const tr_peer**) tr_ptrArrayBase( &t->peers );
|
||||||
ret = tr_new0( tr_peer_stat, size );
|
ret = tr_new0( tr_peer_stat, size );
|
||||||
now = tr_date( );
|
now = tr_time_msec( );
|
||||||
|
|
||||||
for( i=0; i<size; ++i )
|
for( i=0; i<size; ++i )
|
||||||
{
|
{
|
||||||
@@ -2417,7 +2417,7 @@ static void
|
|||||||
rechokeDownloads( Torrent * t )
|
rechokeDownloads( Torrent * t )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const uint64_t now = tr_date( );
|
const uint64_t now = tr_time_msec( );
|
||||||
const int msec = 60 * 1000;
|
const int msec = 60 * 1000;
|
||||||
const int MIN_INTERESTING_PEERS = 5;
|
const int MIN_INTERESTING_PEERS = 5;
|
||||||
const int peerCount = tr_ptrArraySize( &t->peers );
|
const int peerCount = tr_ptrArraySize( &t->peers );
|
||||||
@@ -2743,7 +2743,7 @@ rechokePulse( int foo UNUSED, short bar UNUSED, void * vmgr )
|
|||||||
tr_peerMgr * mgr = vmgr;
|
tr_peerMgr * mgr = vmgr;
|
||||||
managerLock( mgr );
|
managerLock( mgr );
|
||||||
|
|
||||||
now = tr_date( );
|
now = tr_time_msec( );
|
||||||
while(( tor = tr_torrentNext( mgr->session, tor ))) {
|
while(( tor = tr_torrentNext( mgr->session, tor ))) {
|
||||||
if( tor->isRunning ) {
|
if( tor->isRunning ) {
|
||||||
rechokeUploads( tor->torrentPeers, now );
|
rechokeUploads( tor->torrentPeers, now );
|
||||||
@@ -2852,7 +2852,7 @@ getPeersToClose( Torrent * t, tr_close_type_t closeType, const time_t now, int *
|
|||||||
if( shouldPeerBeClosed( t, peers[i], peerCount, now ) == closeType )
|
if( shouldPeerBeClosed( t, peers[i], peerCount, now ) == closeType )
|
||||||
ret[outsize++] = peers[i];
|
ret[outsize++] = peers[i];
|
||||||
|
|
||||||
sortPeersByLivelinessReverse ( ret, NULL, outsize, tr_date( ) );
|
sortPeersByLivelinessReverse ( ret, NULL, outsize, tr_time_msec( ) );
|
||||||
|
|
||||||
*setmeSize = outsize;
|
*setmeSize = outsize;
|
||||||
return ret;
|
return ret;
|
||||||
@@ -3100,7 +3100,7 @@ reconnectPulse( int foo UNUSED, short bar UNUSED, void * vmgr )
|
|||||||
{
|
{
|
||||||
tr_torrent * tor;
|
tr_torrent * tor;
|
||||||
tr_peerMgr * mgr = vmgr;
|
tr_peerMgr * mgr = vmgr;
|
||||||
const uint64_t now = tr_date( );
|
const uint64_t now = tr_time_msec( );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*** enforce the per-session and per-torrent peer limits
|
*** enforce the per-session and per-torrent peer limits
|
||||||
@@ -3445,7 +3445,7 @@ getPeerCandidates( tr_session * session, int * candidateCount )
|
|||||||
struct peer_candidate * candidates;
|
struct peer_candidate * candidates;
|
||||||
struct peer_candidate * walk;
|
struct peer_candidate * walk;
|
||||||
const time_t now = tr_time( );
|
const time_t now = tr_time( );
|
||||||
const uint64_t now_msec = tr_date( );
|
const uint64_t now_msec = tr_time_msec( );
|
||||||
/* leave 5% of connection slots for incoming connections -- ticket #2609 */
|
/* leave 5% of connection slots for incoming connections -- ticket #2609 */
|
||||||
const int maxCandidates = tr_sessionGetPeerLimit( session ) * 0.95;
|
const int maxCandidates = tr_sessionGetPeerLimit( session ) * 0.95;
|
||||||
|
|
||||||
|
|||||||
@@ -1395,7 +1395,7 @@ readBtMessage( tr_peermsgs * msgs, struct evbuffer * inbuf, size_t inlen )
|
|||||||
case BT_UNCHOKE:
|
case BT_UNCHOKE:
|
||||||
dbgmsg( msgs, "got Unchoke" );
|
dbgmsg( msgs, "got Unchoke" );
|
||||||
msgs->peer->clientIsChoked = 0;
|
msgs->peer->clientIsChoked = 0;
|
||||||
updateDesiredRequestCount( msgs, tr_date( ) );
|
updateDesiredRequestCount( msgs, tr_time_msec( ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BT_INTERESTED:
|
case BT_INTERESTED:
|
||||||
@@ -1455,7 +1455,7 @@ readBtMessage( tr_peermsgs * msgs, struct evbuffer * inbuf, size_t inlen )
|
|||||||
tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.index );
|
tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.index );
|
||||||
tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.offset );
|
tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.offset );
|
||||||
tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.length );
|
tr_peerIoReadUint32( msgs->peer->io, inbuf, &r.length );
|
||||||
tr_historyAdd( msgs->peer->cancelsSentToClient, tr_date( ), 1 );
|
tr_historyAdd( msgs->peer->cancelsSentToClient, tr_time_msec( ), 1 );
|
||||||
dbgmsg( msgs, "got a Cancel %u:%u->%u", r.index, r.offset, r.length );
|
dbgmsg( msgs, "got a Cancel %u:%u->%u", r.index, r.offset, r.length );
|
||||||
|
|
||||||
for( i=0; i<msgs->peer->pendingReqsToClient; ++i ) {
|
for( i=0; i<msgs->peer->pendingReqsToClient; ++i ) {
|
||||||
@@ -1929,7 +1929,7 @@ fillOutputBuffer( tr_peermsgs * msgs, time_t now )
|
|||||||
tr_peerIoWriteBuf( io, out, TRUE );
|
tr_peerIoWriteBuf( io, out, TRUE );
|
||||||
bytesWritten += EVBUFFER_LENGTH( out );
|
bytesWritten += EVBUFFER_LENGTH( out );
|
||||||
msgs->clientSentAnythingAt = now;
|
msgs->clientSentAnythingAt = now;
|
||||||
tr_historyAdd( msgs->peer->blocksSentToPeer, tr_date( ), 1 );
|
tr_historyAdd( msgs->peer->blocksSentToPeer, tr_time_msec( ), 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
evbuffer_free( out );
|
evbuffer_free( out );
|
||||||
@@ -1972,7 +1972,7 @@ peerPulse( void * vmsgs )
|
|||||||
const time_t now = tr_time( );
|
const time_t now = tr_time( );
|
||||||
|
|
||||||
if ( tr_isPeerIo( msgs->peer->io ) ) {
|
if ( tr_isPeerIo( msgs->peer->io ) ) {
|
||||||
updateDesiredRequestCount( msgs, tr_date( ) );
|
updateDesiredRequestCount( msgs, tr_time_msec( ) );
|
||||||
updateBlockRequests( msgs );
|
updateBlockRequests( msgs );
|
||||||
updateMetadataRequests( msgs, now );
|
updateMetadataRequests( msgs, now );
|
||||||
}
|
}
|
||||||
@@ -2360,7 +2360,7 @@ tr_peerMsgsNew( struct tr_torrent * torrent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
tr_peerIoSetIOFuncs( m->peer->io, canRead, didWrite, gotError, m );
|
tr_peerIoSetIOFuncs( m->peer->io, canRead, didWrite, gotError, m );
|
||||||
updateDesiredRequestCount( m, tr_date( ) );
|
updateDesiredRequestCount( m, tr_time_msec( ) );
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ rateForInterval( const tr_ratecontrol * r,
|
|||||||
uint64_t now )
|
uint64_t now )
|
||||||
{
|
{
|
||||||
uint64_t bytes = 0;
|
uint64_t bytes = 0;
|
||||||
const uint64_t cutoff = (now?now:tr_date()) - interval_msec;
|
const uint64_t cutoff = (now?now:tr_time_msec()) - interval_msec;
|
||||||
int i = r->newest;
|
int i = r->newest;
|
||||||
|
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
@@ -76,7 +76,7 @@ void
|
|||||||
tr_rcTransferred( tr_ratecontrol * r,
|
tr_rcTransferred( tr_ratecontrol * r,
|
||||||
size_t size )
|
size_t size )
|
||||||
{
|
{
|
||||||
const uint64_t now = tr_date ( );
|
const uint64_t now = tr_time_msec ( );
|
||||||
|
|
||||||
if( r->transfers[r->newest].date + TR_RC_GRANULARITY_MSEC >= now )
|
if( r->transfers[r->newest].date + TR_RC_GRANULARITY_MSEC >= now )
|
||||||
r->transfers[r->newest].size += size;
|
r->transfers[r->newest].size += size;
|
||||||
|
|||||||
@@ -976,7 +976,7 @@ tr_torrentStat( tr_torrent * tor )
|
|||||||
&s->peersGettingFromUs,
|
&s->peersGettingFromUs,
|
||||||
s->peersFrom );
|
s->peersFrom );
|
||||||
|
|
||||||
now = tr_date( );
|
now = tr_time_msec( );
|
||||||
d = tr_peerMgrGetWebseedSpeed_Bps( tor, now );
|
d = tr_peerMgrGetWebseedSpeed_Bps( tor, now );
|
||||||
s->rawUploadSpeed_KBps = toSpeedKBps( tr_bandwidthGetRawSpeed_Bps ( tor->bandwidth, now, TR_UP ) );
|
s->rawUploadSpeed_KBps = toSpeedKBps( tr_bandwidthGetRawSpeed_Bps ( tor->bandwidth, now, TR_UP ) );
|
||||||
s->pieceUploadSpeed_KBps = toSpeedKBps( tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_UP ) );
|
s->pieceUploadSpeed_KBps = toSpeedKBps( tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_UP ) );
|
||||||
|
|||||||
@@ -785,7 +785,7 @@ tr_str_has_suffix( const char *str, const char *suffix )
|
|||||||
****/
|
****/
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
tr_date( void )
|
tr_time_msec( void )
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ void tr_timerAddMsec( struct event * timer, int milliseconds ) TR_GNUC_NONNULL(1
|
|||||||
|
|
||||||
|
|
||||||
/** @brief return the current date in milliseconds */
|
/** @brief return the current date in milliseconds */
|
||||||
uint64_t tr_date( void );
|
uint64_t tr_time_msec( void );
|
||||||
|
|
||||||
/** @brief sleep the specified number of milliseconds */
|
/** @brief sleep the specified number of milliseconds */
|
||||||
void tr_wait_msec( long int delay_milliseconds );
|
void tr_wait_msec( long int delay_milliseconds );
|
||||||
|
|||||||
Reference in New Issue
Block a user