mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Use coarse monotonic timer instead of cached monotonized libevent time.
This commit is contained in:
+4
-5
@@ -405,7 +405,7 @@ static chunk_t *
|
||||
buf_add_chunk_with_capacity(buf_t *buf, size_t capacity, int capped)
|
||||
{
|
||||
chunk_t *chunk;
|
||||
struct timeval now;
|
||||
|
||||
if (CHUNK_ALLOC_SIZE(capacity) < buf->default_chunk_size) {
|
||||
chunk = chunk_new_with_alloc_size(buf->default_chunk_size);
|
||||
} else if (capped && CHUNK_ALLOC_SIZE(capacity) > MAX_CHUNK_ALLOC) {
|
||||
@@ -414,8 +414,7 @@ buf_add_chunk_with_capacity(buf_t *buf, size_t capacity, int capped)
|
||||
chunk = chunk_new_with_alloc_size(preferred_chunk_size(capacity));
|
||||
}
|
||||
|
||||
tor_gettimeofday_cached_monotonic(&now);
|
||||
chunk->inserted_time = (uint32_t)tv_to_msec(&now);
|
||||
chunk->inserted_time = (uint32_t)monotime_coarse_absolute_msec();
|
||||
|
||||
if (buf->tail) {
|
||||
tor_assert(buf->head);
|
||||
@@ -430,8 +429,8 @@ buf_add_chunk_with_capacity(buf_t *buf, size_t capacity, int capped)
|
||||
}
|
||||
|
||||
/** Return the age of the oldest chunk in the buffer <b>buf</b>, in
|
||||
* milliseconds. Requires the current time, in truncated milliseconds since
|
||||
* the epoch, as its input <b>now</b>.
|
||||
* milliseconds. Requires the current monotonic time, in truncated msec,
|
||||
* as its input <b>now</b>.
|
||||
*/
|
||||
uint32_t
|
||||
buf_get_oldest_chunk_timestamp(const buf_t *buf, uint32_t now)
|
||||
|
||||
@@ -2015,7 +2015,7 @@ circuit_max_queued_cell_age(const circuit_t *c, uint32_t now)
|
||||
|
||||
/** Return the age in milliseconds of the oldest buffer chunk on <b>conn</b>,
|
||||
* where age is taken in milliseconds before the time <b>now</b> (in truncated
|
||||
* milliseconds since the epoch). If the connection has no data, treat
|
||||
* absolute monotonic msec). If the connection has no data, treat
|
||||
* it as having age zero.
|
||||
**/
|
||||
static uint32_t
|
||||
@@ -2138,7 +2138,6 @@ circuits_handle_oom(size_t current_allocation)
|
||||
size_t mem_recovered=0;
|
||||
int n_circuits_killed=0;
|
||||
int n_dirconns_killed=0;
|
||||
struct timeval now;
|
||||
uint32_t now_ms;
|
||||
log_notice(LD_GENERAL, "We're low on memory. Killing circuits with "
|
||||
"over-long queues. (This behavior is controlled by "
|
||||
@@ -2152,8 +2151,7 @@ circuits_handle_oom(size_t current_allocation)
|
||||
mem_to_recover = current_allocation - mem_target;
|
||||
}
|
||||
|
||||
tor_gettimeofday_cached_monotonic(&now);
|
||||
now_ms = (uint32_t)tv_to_msec(&now);
|
||||
now_ms = (uint32_t)monotime_coarse_absolute_msec();
|
||||
|
||||
circlist = circuit_get_global_list();
|
||||
SMARTLIST_FOREACH_BEGIN(circlist, circuit_t *, circ) {
|
||||
|
||||
+1
-3
@@ -2320,14 +2320,12 @@ cell_queue_append_packed_copy(circuit_t *circ, cell_queue_t *queue,
|
||||
int exitward, const cell_t *cell,
|
||||
int wide_circ_ids, int use_stats)
|
||||
{
|
||||
struct timeval now;
|
||||
packed_cell_t *copy = packed_cell_copy(cell, wide_circ_ids);
|
||||
(void)circ;
|
||||
(void)exitward;
|
||||
(void)use_stats;
|
||||
tor_gettimeofday_cached_monotonic(&now);
|
||||
|
||||
copy->inserted_time = (uint32_t)tv_to_msec(&now);
|
||||
copy->inserted_time = (uint32_t) monotime_coarse_absolute_msec();
|
||||
|
||||
cell_queue_append(queue, copy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user