aboutsummaryrefslogtreecommitdiff
path: root/src/or/relay.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-02-25 15:58:53 -0500
committerNick Mathewson <nickm@torproject.org>2014-02-25 15:58:53 -0500
commitc3800f631b7fb837d8eb03cc0edc4d8a6454aef9 (patch)
tree376d6772f13c35bbab99afd834736e752b979e8b /src/or/relay.c
parentd7950eda2bfd927a18df4a2620952d10dda1705c (diff)
parent3133cde3c12a814fab4c83ba59d5dfeace397ebc (diff)
downloadtor-c3800f631b7fb837d8eb03cc0edc4d8a6454aef9.tar
tor-c3800f631b7fb837d8eb03cc0edc4d8a6454aef9.tar.gz
Merge remote-tracking branch 'public/no_itime_queue' into maint-0.2.4
Diffstat (limited to 'src/or/relay.c')
-rw-r--r--src/or/relay.c83
1 files changed, 7 insertions, 76 deletions
diff --git a/src/or/relay.c b/src/or/relay.c
index 57633f86a..7f06c6e14 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -2042,10 +2042,6 @@ static size_t total_cells_allocated = 0;
/** A memory pool to allocate packed_cell_t objects. */
static mp_pool_t *cell_pool = NULL;
-/** Memory pool to allocate insertion_time_elem_t objects used for cell
- * statistics. */
-static mp_pool_t *it_pool = NULL;
-
/** Allocate structures to hold cells. */
void
init_cell_pool(void)
@@ -2064,10 +2060,6 @@ free_cell_pool(void)
mp_pool_destroy(cell_pool);
cell_pool = NULL;
}
- if (it_pool) {
- mp_pool_destroy(it_pool);
- it_pool = NULL;
- }
}
/** Free excess storage in cell pool. */
@@ -2156,36 +2148,6 @@ cell_queue_append_packed_copy(cell_queue_t *queue, const cell_t *cell,
tor_gettimeofday_cached(&now);
copy->inserted_time = (uint32_t)tv_to_msec(&now);
- /* Remember the time when this cell was put in the queue. */
- /*XXXX This may be obsoleted by inserted_time */
- if (get_options()->CellStatistics) {
- uint32_t added;
- insertion_time_queue_t *it_queue = queue->insertion_times;
- if (!it_pool)
- it_pool = mp_pool_new(sizeof(insertion_time_elem_t), 1024);
-
-#define SECONDS_IN_A_DAY 86400L
- added = (uint32_t)(((now.tv_sec % SECONDS_IN_A_DAY) * 100L)
- + ((uint32_t)now.tv_usec / (uint32_t)10000L));
- if (!it_queue) {
- it_queue = tor_malloc_zero(sizeof(insertion_time_queue_t));
- queue->insertion_times = it_queue;
- }
- if (it_queue->last && it_queue->last->insertion_time == added) {
- it_queue->last->counter++;
- } else {
- insertion_time_elem_t *elem = mp_pool_get(it_pool);
- elem->next = NULL;
- elem->insertion_time = added;
- elem->counter = 1;
- if (it_queue->last) {
- it_queue->last->next = elem;
- it_queue->last = elem;
- } else {
- it_queue->first = it_queue->last = elem;
- }
- }
- }
cell_queue_append(queue, copy);
}
@@ -2202,14 +2164,6 @@ cell_queue_clear(cell_queue_t *queue)
}
queue->head = queue->tail = NULL;
queue->n = 0;
- if (queue->insertion_times) {
- while (queue->insertion_times->first) {
- insertion_time_elem_t *elem = queue->insertion_times->first;
- queue->insertion_times->first = elem->next;
- mp_pool_release(elem);
- }
- tor_free(queue->insertion_times);
- }
}
/** Extract and return the cell at the head of <b>queue</b>; return NULL if
@@ -2234,9 +2188,7 @@ cell_queue_pop(cell_queue_t *queue)
size_t
packed_cell_mem_cost(void)
{
- return sizeof(packed_cell_t) + MP_POOL_ITEM_OVERHEAD +
- get_options()->CellStatistics ?
- (sizeof(insertion_time_elem_t)+MP_POOL_ITEM_OVERHEAD) : 0;
+ return sizeof(packed_cell_t) + MP_POOL_ITEM_OVERHEAD;
}
/** Check whether we've got too much space used for cells. If so,
@@ -2415,35 +2367,14 @@ channel_flush_from_first_active_circuit(channel_t *chan, int max)
/* Calculate the exact time that this cell has spent in the queue. */
if (get_options()->CellStatistics && !CIRCUIT_IS_ORIGIN(circ)) {
+ uint32_t msec_waiting;
struct timeval tvnow;
- uint32_t flushed;
- uint32_t cell_waiting_time;
- insertion_time_queue_t *it_queue = queue->insertion_times;
+ or_circ = TO_OR_CIRCUIT(circ);
tor_gettimeofday_cached(&tvnow);
- flushed = (uint32_t)((tvnow.tv_sec % SECONDS_IN_A_DAY) * 100L +
- (uint32_t)tvnow.tv_usec / (uint32_t)10000L);
- if (!it_queue || !it_queue->first) {
- log_info(LD_GENERAL, "Cannot determine insertion time of cell. "
- "Looks like the CellStatistics option was "
- "recently enabled.");
- } else {
- insertion_time_elem_t *elem = it_queue->first;
- or_circ = TO_OR_CIRCUIT(circ);
- cell_waiting_time =
- (uint32_t)((flushed * 10L + SECONDS_IN_A_DAY * 1000L -
- elem->insertion_time * 10L) %
- (SECONDS_IN_A_DAY * 1000L));
-#undef SECONDS_IN_A_DAY
- elem->counter--;
- if (elem->counter < 1) {
- it_queue->first = elem->next;
- if (elem == it_queue->last)
- it_queue->last = NULL;
- mp_pool_release(elem);
- }
- or_circ->total_cell_waiting_time += cell_waiting_time;
- or_circ->processed_cells++;
- }
+ msec_waiting = ((uint32_t)tv_to_msec(&tvnow)) - cell->inserted_time;
+
+ or_circ->total_cell_waiting_time += msec_waiting;
+ or_circ->processed_cells++;
}
/* If we just flushed our queue and this circuit is used for a