/* For uTP sockets, the overhead is computed in utp_on_overhead. */
const unsigned int overhead =
io->socket ? guessPacketOverhead( payload ) : 0;
- const uint64_t now = tr_sessionGetTimeMsec( io->session );
+ const uint64_t now = tr_time_msec( );
tr_bandwidthUsed( &io->bandwidth, TR_UP, payload, next->isPieceData, now );
/* try to consume the input buffer */
if( io->canRead )
{
- const uint64_t now = tr_sessionGetTimeMsec( io->session );
+ const uint64_t now = tr_time_msec( );
tr_sessionLock( session );
{
tr_torrent * tor = NULL;
tr_peerMgr * mgr = vmgr;
- const uint64_t now = tr_sessionGetTimeMsec( mgr->session );
+ const uint64_t now = tr_time_msec( );
managerLock( mgr );
tr_torrent * tor;
tr_peerMgr * mgr = vmgr;
const time_t now_sec = tr_time( );
- const uint64_t now_msec = tr_sessionGetTimeMsec( mgr->session );
+ const uint64_t now_msec = tr_time_msec( );
/**
*** enforce the per-session and per-torrent peer limits
{
session->curl_easy_config_func = func;
}
-
-/***
-****
-***/
-
-uint64_t
-tr_sessionGetTimeMsec( tr_session * session )
-{
- struct timeval tv;
-
- if( event_base_gettimeofday_cached( session->event_base, &tv ) )
- {
- return tr_time_msec( );
- }
- else
- {
- /* event_base_gettimeofday_cached() might be implemented using
- clock_gettime(CLOCK_MONOTONIC), so calculate the offset to
- real time... */
- static uint64_t offset;
- static tr_bool offset_calculated = FALSE;
-
- const uint64_t val = (uint64_t) tv.tv_sec * 1000 + ( tv.tv_usec / 1000 );
-
- if( !offset_calculated )
- {
- offset = tr_time_msec() - val;
- offset_calculated = TRUE;
- }
-
- return val + offset;
- }
-}
tr_direction dir,
int * setme );
-
-/**
- * Tries to use libevent's cached timeval so we can avoid excessive calls
- * to gettimeofday().
- *
- * This isn't for all uses, but should be reasonably accurate when called
- * near the beginning of a libevent callback.
- */
-uint64_t tr_sessionGetTimeMsec( tr_session * session );
-
-
#endif