aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-07-19 11:42:26 +0200
committerNick Mathewson <nickm@torproject.org>2016-07-19 11:42:26 +0200
commit558f7d3701ef0236e0bf2886dca538cfe1ad18bd (patch)
tree5061f1d23616afb2ccebc097262c37b083540d71 /src/or
parent94c27d4e8fede72b128e0bbdd8b60d77ed23ebe6 (diff)
parent1e3cf1cc8321ec29acaae6acb22340f0e2f5e9da (diff)
downloadtor-558f7d3701ef0236e0bf2886dca538cfe1ad18bd.tar.gz
tor-558f7d3701ef0236e0bf2886dca538cfe1ad18bd.zip
Merge branch 'monotonic_v2_squashed'
Diffstat (limited to 'src/or')
-rw-r--r--src/or/buffers.c9
-rw-r--r--src/or/circuitlist.c6
-rw-r--r--src/or/main.c2
-rw-r--r--src/or/relay.c4
4 files changed, 9 insertions, 12 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 8b9a53c699..970d17ee41 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -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)
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index d2ba7d4781..5c691644a4 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -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) {
diff --git a/src/or/main.c b/src/or/main.c
index 404d741c38..76af910b3e 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -3646,6 +3646,8 @@ tor_main(int argc, char *argv[])
#endif
}
+ monotime_init();
+
switch (get_options()->command) {
case CMD_RUN_TOR:
#ifdef NT_SERVICE
diff --git a/src/or/relay.c b/src/or/relay.c
index fb8c8e74d6..a815a55d69 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -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);
}