]> granicus.if.org Git - transmission/commitdiff
(trunk libt) rename tr_date() as tr_time_msec() for clarity
authorCharles Kerr <charles@transmissionbt.com>
Sun, 11 Jul 2010 20:49:19 +0000 (20:49 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Sun, 11 Jul 2010 20:49:19 +0000 (20:49 +0000)
libtransmission/bandwidth.c
libtransmission/crypto.c
libtransmission/fdlimit.c
libtransmission/history.c
libtransmission/history.h
libtransmission/peer-mgr.c
libtransmission/peer-msgs.c
libtransmission/ratecontrol.c
libtransmission/torrent.c
libtransmission/utils.c
libtransmission/utils.h

index e8ccd349aaa5faefef12957abc0e3aae8d443f2a..ff2e93a9f2272a564629fbbd8c441317f57f4a9c 100644 (file)
@@ -34,7 +34,7 @@ static unsigned int
 getSpeed_Bps( const struct bratecontrol * r, unsigned int interval_msec, uint64_t now )
 {
     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;
 
     for( ;; )
@@ -381,5 +381,5 @@ tr_bandwidthUsed( tr_bandwidth  * b,
                   size_t          byteCount,
                   tr_bool         isPieceData )
 {
-    bandwidthUsedImpl( b, dir, byteCount, isPieceData, tr_date( ) );
+    bandwidthUsedImpl( b, dir, byteCount, isPieceData, tr_time_msec( ) );
 }
index dce13faced2e2b95292efbe6ca9035f4eb2bbfe4..5e8b01b3bcd527aedeafb05972fc24857a089192 100644 (file)
@@ -347,7 +347,7 @@ tr_cryptoWeakRandInt( int upperBound )
 
     if( !init )
     {
-        srand( tr_date( ) );
+        srand( tr_time_msec( ) );
         init = TRUE;
     }
 
index 51ab6dc94d35f9633b4d8ee78d6872926360850b..7ca8415157dbfbaa3e7aab8f669599bf9798a8f8 100644 (file)
@@ -474,7 +474,7 @@ tr_fdFileGetCached( tr_session       * session,
 
     if( ( match != NULL ) && ( !doWrite || match->isWritable ) )
     {
-        match->date = tr_date( );
+        match->date = tr_time_msec( );
         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." );
     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 */
         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 );
     o->torrentId = torrentId;
     o->fileNum = fileNum;
-    o->date = tr_date( );
+    o->date = tr_time_msec( );
     return o->fd;
 }
 
index e0bd93e81ce779da7cd8559d35dd3770625715f1..0106a04295decd0b7469581d8a04264d8b51fdf9 100644 (file)
@@ -44,7 +44,7 @@ unsigned int
 tr_historyGet( const tr_recentHistory * h, uint64_t now, unsigned int msec )
 {
     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;
 
     for( ;; )
index 27c7de738310744bcaa4399f9212ffa25e66cbee..f0010006d5b991a6e42f84be4c1dfdc95135fae1 100644 (file)
@@ -39,14 +39,14 @@ void tr_historyFree( tr_recentHistory * );
 
 /**
  * @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
  */
 void tr_historyAdd( tr_recentHistory *, uint64_t when, unsigned int n );
 
 /**
  * @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.
  */
 unsigned int tr_historyGet( const tr_recentHistory *, uint64_t when, unsigned int seconds );
index 2749cd9ba3f84583da9cc1c77b13ee0fe9d2921c..79a691048722537b0daa74fe103e021cf2dcd416 100644 (file)
@@ -1183,7 +1183,7 @@ refillUpkeep( int foo UNUSED, short bar UNUSED, void * vmgr )
     managerLock( mgr );
 
     now = tr_time( );
-    now_msec = tr_date( );
+    now_msec = tr_time_msec( );
     too_old = now - REQUEST_TTL_SECS;
 
     tor = NULL;
@@ -1437,7 +1437,7 @@ peerCallbackFunc( tr_peer * peer, const tr_peer_event * e, void * vt )
             pieceListRemoveRequest( t, block );
 
             if( peer != NULL )
-                tr_historyAdd( peer->blocksSentToClient, tr_date( ), 1 );
+                tr_historyAdd( peer->blocksSentToClient, tr_time_msec( ), 1 );
 
             if( tr_cpBlockIsComplete( &tor->completion, block ) )
             {
@@ -2286,7 +2286,7 @@ tr_peerMgrWebSpeeds_KBps( const tr_torrent * tor )
     webseedCount = tr_ptrArraySize( &t->webseeds );
     assert( webseedCount == tor->info.webseedCount );
     ret = tr_new0( double, webseedCount );
-    now = tr_date( );
+    now = tr_time_msec( );
 
     for( i=0; i<webseedCount; ++i ) {
         int Bps;
@@ -2324,7 +2324,7 @@ tr_peerMgrPeerStats( const tr_torrent    * tor,
     size = tr_ptrArraySize( &t->peers );
     peers = (const tr_peer**) tr_ptrArrayBase( &t->peers );
     ret = tr_new0( tr_peer_stat, size );
-    now = tr_date( );
+    now = tr_time_msec( );
 
     for( i=0; i<size; ++i )
     {
@@ -2417,7 +2417,7 @@ static void
 rechokeDownloads( Torrent * t )
 {
     int i;
-    const uint64_t now = tr_date( );
+    const uint64_t now = tr_time_msec( );
     const int msec = 60 * 1000;
     const int MIN_INTERESTING_PEERS = 5;
     const int peerCount = tr_ptrArraySize( &t->peers );
@@ -2743,7 +2743,7 @@ rechokePulse( int foo UNUSED, short bar UNUSED, void * vmgr )
     tr_peerMgr * mgr = vmgr;
     managerLock( mgr );
 
-    now = tr_date( );
+    now = tr_time_msec( );
     while(( tor = tr_torrentNext( mgr->session, tor ))) {
         if( tor->isRunning ) {
             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 )
             ret[outsize++] = peers[i];
 
-    sortPeersByLivelinessReverse ( ret, NULL, outsize, tr_date( ) );
+    sortPeersByLivelinessReverse ( ret, NULL, outsize, tr_time_msec( ) );
 
     *setmeSize = outsize;
     return ret;
@@ -3100,7 +3100,7 @@ reconnectPulse( int foo UNUSED, short bar UNUSED, void * vmgr )
 {
     tr_torrent * tor;
     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
@@ -3445,7 +3445,7 @@ getPeerCandidates( tr_session * session, int * candidateCount )
     struct peer_candidate * candidates;
     struct peer_candidate * walk;
     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 */
     const int maxCandidates = tr_sessionGetPeerLimit( session ) * 0.95;
 
index 88d8fe1a9f2b9da54583e915ecab5ee8ba230d28..9e9d77db8bff195cc7707a73dacce6abfb461d67 100644 (file)
@@ -1395,7 +1395,7 @@ readBtMessage( tr_peermsgs * msgs, struct evbuffer * inbuf, size_t inlen )
         case BT_UNCHOKE:
             dbgmsg( msgs, "got Unchoke" );
             msgs->peer->clientIsChoked = 0;
-            updateDesiredRequestCount( msgs, tr_date( ) );
+            updateDesiredRequestCount( msgs, tr_time_msec( ) );
             break;
 
         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.offset );
             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 );
 
             for( i=0; i<msgs->peer->pendingReqsToClient; ++i ) {
@@ -1929,7 +1929,7 @@ fillOutputBuffer( tr_peermsgs * msgs, time_t now )
                 tr_peerIoWriteBuf( io, out, TRUE );
                 bytesWritten += EVBUFFER_LENGTH( out );
                 msgs->clientSentAnythingAt = now;
-                tr_historyAdd( msgs->peer->blocksSentToPeer, tr_date( ), 1 );
+                tr_historyAdd( msgs->peer->blocksSentToPeer, tr_time_msec( ), 1 );
             }
 
             evbuffer_free( out );
@@ -1972,7 +1972,7 @@ peerPulse( void * vmsgs )
     const time_t  now = tr_time( );
 
     if ( tr_isPeerIo( msgs->peer->io ) ) {
-        updateDesiredRequestCount( msgs, tr_date( ) );
+        updateDesiredRequestCount( msgs, tr_time_msec( ) );
         updateBlockRequests( msgs );
         updateMetadataRequests( msgs, now );
     }
@@ -2360,7 +2360,7 @@ tr_peerMsgsNew( struct tr_torrent    * torrent,
     }
 
     tr_peerIoSetIOFuncs( m->peer->io, canRead, didWrite, gotError, m );
-    updateDesiredRequestCount( m, tr_date( ) );
+    updateDesiredRequestCount( m, tr_time_msec( ) );
 
     return m;
 }
index 2fbc23ce684dee2c7d0e26343bfc3412f2591ae7..af29ed10b2f8bbfb679dc4c92775644790d5e174 100644 (file)
@@ -36,7 +36,7 @@ rateForInterval( const tr_ratecontrol * r,
                  uint64_t               now )
 {
     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;
 
     for( ; ; )
@@ -76,7 +76,7 @@ void
 tr_rcTransferred( tr_ratecontrol * r,
                   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 )
         r->transfers[r->newest].size += size;
index 5e8d4dd7199ddf80b8bd243f9e9cb7448d6621da..ac4fbce5ec7225277b965fbef6124e182ccb6aa6 100644 (file)
@@ -976,7 +976,7 @@ tr_torrentStat( tr_torrent * tor )
                             &s->peersGettingFromUs,
                             s->peersFrom );
 
-    now = tr_date( );
+    now = tr_time_msec( );
     d = tr_peerMgrGetWebseedSpeed_Bps( tor, now );
     s->rawUploadSpeed_KBps     = toSpeedKBps( tr_bandwidthGetRawSpeed_Bps  ( tor->bandwidth, now, TR_UP ) );
     s->pieceUploadSpeed_KBps   = toSpeedKBps( tr_bandwidthGetPieceSpeed_Bps( tor->bandwidth, now, TR_UP ) );
index 4acc3c44847b45bef7d2b225bf391d454cbd9bd3..5a54b3cfe5744e3b5e53abc67c2d0e815a185d8f 100644 (file)
@@ -785,7 +785,7 @@ tr_str_has_suffix( const char *str, const char *suffix )
 ****/
 
 uint64_t
-tr_date( void )
+tr_time_msec( void )
 {
     struct timeval tv;
 
index 0c1ad757c6403156e4c96a9d66140f7648e62ca4..62e24843fec6aba13494cce5bfd3397b406f8c6f 100644 (file)
@@ -265,7 +265,7 @@ void tr_timerAddMsec( struct event * timer, int milliseconds ) TR_GNUC_NONNULL(1
 
 
 /** @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 */
 void tr_wait_msec( long int delay_milliseconds );