Changeset 11783
- Timestamp:
- Jan 29, 2011, 6:59:23 PM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-io.c
r11718 r11783 87 87 }; 88 88 89 89 90 /*** 90 91 **** … … 100 101 const unsigned int payload = MIN( next->length, bytes_transferred ); 101 102 const unsigned int overhead = guessPacketOverhead( payload ); 102 const uint64_t now = tr_ time_msec();103 const uint64_t now = tr_sessionGetTimeMsec( io->session ); 103 104 104 105 tr_bandwidthUsed( &io->bandwidth, TR_UP, payload, next->isPieceData, now ); … … 140 141 if( io->canRead ) 141 142 { 143 const uint64_t now = tr_sessionGetTimeMsec( io->session ); 144 142 145 tr_sessionLock( session ); 143 146 … … 149 152 const size_t used = oldLen - evbuffer_get_length( io->inbuf ); 150 153 const unsigned int overhead = guessPacketOverhead( used ); 151 const uint64_t now = tr_time_msec( );152 154 153 155 assert( tr_isPeerIo( io ) ); -
trunk/libtransmission/peer-mgr.c
r11709 r11783 2751 2751 rechokePulse( int foo UNUSED, short bar UNUSED, void * vmgr ) 2752 2752 { 2753 uint64_t now;2754 2753 tr_torrent * tor = NULL; 2755 2754 tr_peerMgr * mgr = vmgr; 2755 const uint64_t now = tr_sessionGetTimeMsec( mgr->session ); 2756 2756 2757 managerLock( mgr ); 2757 2758 2758 now = tr_time_msec( );2759 2759 while(( tor = tr_torrentNext( mgr->session, tor ))) { 2760 2760 if( tor->isRunning ) { … … 3114 3114 tr_peerMgr * mgr = vmgr; 3115 3115 const time_t now_sec = tr_time( ); 3116 const uint64_t now_msec = tr_ time_msec();3116 const uint64_t now_msec = tr_sessionGetTimeMsec( mgr->session ); 3117 3117 3118 3118 /** -
trunk/libtransmission/session.c
r11781 r11783 2559 2559 session->curl_easy_config_func = func; 2560 2560 } 2561 2562 /*** 2563 **** 2564 ***/ 2565 2566 uint64_t 2567 tr_sessionGetTimeMsec( tr_session * session ) 2568 { 2569 struct timeval tv; 2570 2571 if( event_base_gettimeofday_cached( session->event_base, &tv ) ) 2572 { 2573 return tr_time_msec( ); 2574 } 2575 else 2576 { 2577 /* event_base_gettimeofday_cached() might be implemented using 2578 clock_gettime(CLOCK_MONOTONIC), so calculate the offset to 2579 real time... */ 2580 static uint64_t offset; 2581 static tr_bool offset_calculated = FALSE; 2582 2583 const uint64_t val = (uint64_t) tv.tv_sec * 1000 + ( tv.tv_usec / 1000 ); 2584 2585 if( !offset_calculated ) 2586 { 2587 offset = tr_time_msec() - val; 2588 offset_calculated = TRUE; 2589 } 2590 2591 return val + offset; 2592 } 2593 } -
trunk/libtransmission/session.h
r11709 r11783 306 306 307 307 308 /** 309 * Tries to use libevent's cached timeval so we can avoid excessive calls 310 * to gettimeofday(). 311 * 312 * This isn't for all uses, but should be reasonably accurate when called 313 * near the beginning of a libevent callback. 314 */ 315 uint64_t tr_sessionGetTimeMsec( tr_session * session ); 316 317 308 318 #endif
Note: See TracChangeset
for help on using the changeset viewer.